DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS...

81
DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5) Database Program: Microsoft Access Series Instructor: Michael Kremer, Ph.D. Technology & Information Management Section 1

Transcript of DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS...

Page 1: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

DEVELOPING DATABASE APPLICATIONS

(INTERMEDIATE MICROSOFT ACCESS, X405.5)

Database Program: Microsoft Access Series

Instructor: Michael Kremer, Ph.D.Technology & Information Management

Section 1

Page 2: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

WHO AM I?

Michael Kremer

Currently: Federal Reserve Bank

Previously: Lawrence Berkeley Laboratory

Database/Application Developer

dBase, Access Developer for over 20 years

Instructor for UC Extension since 1998

DB: Oracle, SQL Server, Access

Prog.: ASP.net. C#, VB/VBA, Java/Javascript

Reporting: Cognos, Actuate

Page 3: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

WHO ARE YOU?

Name/Company/Organization

What do you do?

Computer Experience (OS, Application SW,

Other Classes Taken, etc.)

MS Access Experience

Expectations/Goals

Any other information about you such as

hobbies, special interests, fun facts, etc.

Page 4: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

AGENDA

1. Introduction to Application Development

2. Exchanging Data using MS Access

3. Linking External Data

4. Importing External Data

5. Exporting MS Access Data

6. Linking MS Access Tables

Page 5: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Introduction to Application Development

1.

Page 6: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.1 APPLICATION DEVELOPMENT STEPS

Database design is only one step within the Software

Development Life Cycle (SDLC) process.

System Analysis is a main step before database design

Planning Phase.

Clearly identify scope and goals.

Planning phase sets boundaries for the application process.

Make sure that everyone involved in the project agrees on the

goals and the scopes of the project.

System Analysis:

Determine goal of the overall project (not only the system).

Establish system design’s criteria (yard stick)

Define clearly scope

1

Page 7: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.1 APPLICATION DEVELOPMENT STEPS

Next step is

database design:

Data collection

Identifying data

elements

Data Normalization

Conceptual model

is independent of physical implementation

Refine conceptual model and transform it into a logical model (particular data

model such as relational, hierarchical, object-oriented).

Then transform logical model into physical database.

After building the database the user interface must be designed.

Selecting application software, prototype forms/reports, navigational system.

Finally application can be built in its entirety.

User interface is the main bridge between technical community and diverse

user community Very important.

2

Page 8: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.1 APPLICATION DEVELOPMENT STEPS

Important aspects about user interfaces:

Consistency

Forgiveness

Simplicity

Aesthetics

Feedback

Testing is an important step before application is released.

Review all aspects of the application with all parties involved.

Refine the application, if necessary, and test again.

Once testing is done, distribute the application (installing).

Last two steps are mostly neglected due to time constraints:

Documenting an application is as crucial as training the users on the new application.

Documentation is important in the future to help support staff maintain and upgrade an

application.

Initial and possibly ongoing user training is critical to obtaining accurate data stored in the

database.

3

Page 9: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.2 LIFE CYCLE MODELS

Ideally, finish one step in SDLC

before starting the next one.

This model assumes that all the

information necessary for each

step is available.

Furthermore, it assumes that the

information remains constant over

the lifetime of the project.

Unfortunately, reality is different

from this approach.

4

Page 10: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.2 LIFE CYCLE MODELS

As we all know, all these

different steps interact with

each other.

There is always a need to

go back and make

adjustments due to new

information discovered

or changed information.

Due to shortcomings of

Waterfall model other

approaches have been

developed.

Spiral model tries to

overcome the lack of flexibility with an iterative repetition of the steps

in waterfall mode.

5

Page 11: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

1.2 LIFE CYCLE MODELS

Entire scope is not considered until very late in the development

phase. One should keep the entire scope of a project in mind at all

times, from the very beginning though the end of the project.

Both models lack certain aspects of the real-world project

development, however, combining them into a new model may work.

The beginning of a project can be modeled after the waterfall model,

(system analysis, the design of database and user interface). After the

initial phase, an approach closer to the spiral model should be taken

to accomplish the remaining steps:

Building the database

Building the interface

Testing the application

Other models:

Iterative and Incremental Development

Agile Development

Rapid Application Development

6

Page 12: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Exchanging Data using MS Access

2.

Page 13: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.1 METHODS OF WORKING WITH EXTERNAL DATA

In today’s information driven society, it is absolutely crucial to

exchange data between different systems.

MS Access is no exception, in fact, due to its versatility in exchanging

data it has become a very popular desktop database product.

Below are categories of applications Access can communicate with:

Other Windows application

Macintosh applications (Foxbase, FoxPro, Excel)

Spreadsheets

PC based database applications

Server-based database applications

Text Files

HTML files

Mail Servers/Clients

Web Services

7

Page 14: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.1 METHODS OF WORKING WITH EXTERNAL DATA

The following lists all native (built-in) file formats:

Access databases(all versions)

MS Excel (*.xls)

Exchange (*.pst)

Outlook (*.pst)

Text files(*.txt, *.csv, *.tab, *.asc)

HTML documents (*.html, *.htm)

SharePoint lists

XML files (*.xml)

Access can export and import data in many different formats.

Incoming data can be imported or linked:

Linking Data: Data remains in its native format outside Access

Importing Data: Data is copied and converted into Access

8

Page 15: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.1 METHODS OF WORKING WITH EXTERNAL DATA

Linking Data

Linking to external data keeps the data in its current file format. There

is no data duplication, and MS Access can make changes (with some

exceptions) to the data, even to the non-native index files.

This is useful when the other application is still in use. However,

performance is degraded due to constant translation of data formats

back and forth between MS Access and the external file format.

Importing Data

Importing the data makes a copy of the data, converts the data into a

MS Access format, and creates tables in MS Access.

More efficient in terms of performance, and useful if the other

application is not in use anymore.

But if the external application is still being used, maintaining data in

two different places causes problems. Also consider that importing a

lot of data increases the size of the MS Access database file.

9

Page 16: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.1 METHODS OF WORKING WITH EXTERNAL DATA

Linking vs. Importing

You should consider importing external data when:

Data is small and is not changed frequently by users of the native system.

No need to share data you create with users of the other database application.

Replacing the old database application and no need of the old formatted data.

Need best performance while working with the external data.

On the other hand, you should consider linking external data when:

The data is too large to be imported into an Access database (~ 2GB).

The data is used and changed frequently in the native application.

You must share the data over the network with other users.

You want to create a multi-user application.

Exporting Data

You can export data in the same formats as importing data

Objects can be tables or queries.

You can also export data back to ODBC datasources!

10

Page 17: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

ODBC stands for Open Database Connectivity and is a windows

interface to establish connections between database applications.

History of ODBC

Access uses SQL for reading and updating data.

Products that “speaks” SQL should be able to talk to each other.

SQL is standardized, but most implementations exhibit variations.

Therefore, 30 companies defined a common base SQL

implementation so that different SQL-based products could talk to

each other Common Language Interface (CLI).

Microsoft developed PC CLI and called it ODBC,

By the end of 1992, more than a dozen vendors committed to

providing ODBC support in their product.

11

Page 18: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

Overview of ODBC

ODBC software acts as a

bridge between two SQL

disparate databases.

In order to setup an ODBC

connection, an ODBC driver

has to be installed.

MS Access was one of the

first ODBC compliant

product.

12

Page 19: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

Use Windows built-in ODBC Driver Manager tool

Control Panel System & Performance, Administrative Tools ODBC

Data Sources

13

Page 20: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

In Windows 7, 32 bit ODBC Manager is installed under

c:\Windows\SysWoW64, search for odbcadm32.exe.

14

Page 21: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

ODBC Administrator Tool is divided

into multiple tabs:

A user DSN is user specific, that

means if a windows login exists, it

is only available to that user.

A system DSN is user independent

meaning anyone having access to

the computer where the data

source is set up can use this DSN.

A file DSN is a portable data source

name where the ODBC set up can be

copied to other computers or installed on the network.

The Drivers tab shows all available drivers installed on the current

local computer.

You will see both, 32-bit and 64-bit drivers, but you can only use the

ones compatible with the launched ODBC Manager (32 or 64-bit).

15

Page 22: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

Creating a Data Source in ODBC Manager

To create an ODBC data source, follow these steps:

First decide on whether to create a User, System, or File DSN.

Select the appropriate DSN tab, and then click Add.

Select the installed driver of the target database, and then click on Finish.

Configure the

data connection,

mainly user

account and

password.

Click the Test Connection button.

Depending on the ODBC driver, a login

dialog box is displayed (example Oracle).

16

Page 23: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

If the connection is successful:

If connection did not succeed:

17

Page 24: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

2.2 ODBC CONNECTIONS

18

Page 25: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Linking External Data

3.

Page 26: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.1 OVERVIEW OF LINKING DATA

Linking data into an MS Access database allows you to build powerful

application components:

Reporting tool to combine data from different sources

Front-end application to link to client server database.

Multi-user applications linking a shared Access back-end.

MS Access is comprised of three different components:

Database Engine: Storing and manager data, integrity, indexes.

Application Layer: Forms, reports, navigation, but also design interfaces such as

table, query, macro designer.

Procedural Programming IDE: Automating database applications and processes by

using procedural programing language (VBA).

19

Page 27: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.1 OVERVIEW OF LINKING DATA

Use Access as an interface for many database systems.

Especially useful for client/server databases.

20

Page 28: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.1 OVERVIEW OF LINKING DATA

To create a linked table, follow these basic steps:

Click on the External Data tab.

In the Import & Link group, select the desired file format you want to link to.

In the first dialog box, select whether to link or import the external data source.

Follow the next steps to complete the linked table connection.

Once a linked table connection is established, the linked table

appears in the Navigation Pane almost like a native table with the

exception of a small arrow pointing to the linked

table.

That arrow indicates that it is a linked table.

Hovering the mouse over the linked table allows

you to view the linked table connection

information

21

Page 29: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

You can link to the following file formats:

Excel (all versions) (read-only)

Access (all versions) (tables only)

ODBC databases

Text files (read-only, but add records)

Share Point Lists

Data Services (Share Point Server)

HTML Document (read-only)

Outlook/Exchange Folder

Note that some of these linked

connections are read-only

depending on the file format.

Many file formats are updatable,

in general.

22

Page 30: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

Selecting the External Data Source

First step is to point to external data source.

Mostly done with File Open Dialog box, ODBC connections through

Manager Tool.

Click on Browse.

After selecting a data

source, additional

steps may be necessary.

Managing Linked Tables

To rename a linked table name, simply select it and right-click on it,

then select rename. Note that you are only renaming the linked table

name and not the source table name.

To delete a linked table, simply select it and press the [Del] key. Again,

you are only deleting the linked table in the current database and not

the source table in the native system.

23

Page 31: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

Linked tables in navigation page

display different icons based on file

format.

In general, you cannot change table

design properties, except application layer properties maintained by

MS Access.

You will receive the following Warning message when entering design

view of a linked table.

Properties that

can be modified.

24

ODBC

Access

dBase

Excel

Html

Text

Page 32: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

Updating Data in Linked Tables

Not all linked tables are updateable.

In general, Excel spreadsheets, text and html files are not updatable,

but you can add new records to a linked table based on a text file.

Linked MS Access and ODBC tables are potentially updatable, but it

depends on how the link is established.

Most importantly, the linked table connection in MS Access needs to

know the primary key of the source table in order to allow data

updates.

Under certain circumstances, MS Access can

identify the primary key of the source data

(depending on ODBC driver) and it will use it when

performing data update operations.

25

Page 33: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

Using Linked Tables

Linked tables in MS Access can be used in the same way as native

tables, that is the beauty about linked tables.

Queries, forms, and reports can be based on linked tables as well as

native tables.

Furthermore, you can create queries and include native and linked

tables. You must establish a link either in the query or use the

relationship builder tool.

However, no referential integrity can

be enforced, the checkbox is grayed

out for any relationship that involves a

linked table as shown

26

Page 34: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

27

Page 35: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

28

Page 36: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

3.2 LINKING EXTERNAL DATA

29

Page 37: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Importing External Data

4.

Page 38: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.1 OVERVIEW OF IMPORTING DATA

When importing data into MS Access you have to consider possible

data type differences or mixed data types in one column.

Since you can import data from text or spreadsheet files, possible

conflicts may exist in terms of data types.

When importing data you go through a series of steps that you may

want to repeat with a certain frequency, for example to import

currency data on a daily basis. For this very reason, the import steps

can be saved during the last step of the import wizard.

This feature allows you to automate the import process by using a

macro or VBA code.

30

Page 39: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.1 OVERVIEW OF IMPORTING DATA

To access the saved

imports (and saved

exports as well) you click

on the Saved Imports

button in the External

Data tab, Import & Link

group.

Select the particular saved

import and click on the

Run button.

You can also delete a

saved import here as well

as create an Microsoft

Outlook task.

31

Page 40: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.1 OVERVIEW OF IMPORTING DATA

32

Page 41: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.1 OVERVIEW OF IMPORTING DATA

Besides saving the import steps, for text files only, you can further

specify the exact composition and position of text data to be imported.

Again, this is for the sole purpose of automating an import process.

For example, for fixed-width text data, the exact character positions of

all columns in the text file can be defined so that the import process

exactly knows how to populate the

fields in a table.

33

Page 42: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.2 IMPORTING EXTERNAL DATA

Importing data into MS Access basically means copying data and

moving them into MS Access.

In addition to importing data, MS Access provides also a tool for

importing other objects such as queries, forms, reports, macros, and

modules from other Access databases.

To import data or objects from another Access database, click on the

External Data tab, then in the Import &

Link section click on Access.

Then the Get External Data – Access

Database dialog box is displayed to select

the file from which data is to be imported

and whether to import or link.

34

Page 43: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.2 IMPORTING EXTERNAL DATA

More Objects:

Relationships

Menus and Toolbars

Import/Export Specifications

Navigation Pane Groups

Images and Themes

More Options:

Import tables:

Definitions and data

Definition only

Import queries

As queries

As tables

35

Page 44: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.2 IMPORTING EXTERNAL DATA

Data type conversion takes place when importing data (defined by

drivers)

36

Page 45: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.3 IMPORTING SPREADSHEET DATA

MS Access allows importing data from Spreadsheet software such as

Excel. However, due to the nature of spreadsheet data (data and text)

two conditions must be met to be able to import data into MS Access:

The data must be arranged in a table like format (rows and columns)

The data must be of the same data type in each column

Spreadsheet data can be as selective as named range in a sheet.

Column Junk will cause problems

because it contains mixed data types.

Whenever Access determines that

data in column is comprised of

different data types, it imports the data as text, if possible.

Access determines the data type based on the values it detects in the

spreadsheet’s first few rows. If the first row contains column headers,

that row is excluded from the determination of the data type.

37

Page 46: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.3 IMPORTING SPREADSHEET DATA

Determination

of data types

If the first couple of rows are not representative of all the data in your

spreadsheet, or if you want to force a text data type for number data,

then insert a dummy row in your spreadsheet with the desired data

type.

38

Page 47: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.3 IMPORTING SPREADSHEET DATA

39

Page 48: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.3 IMPORTING SPREADSHEET DATA

40

Page 49: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.3 IMPORTING SPREADSHEET DATA

41

Page 50: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

Data from word processing files cannot be imported directly into MS

Access. However, most word processors allow you to save a file in a

simple text or ASCII format.

Additionally, when you need to exchange data between systems where

no native or non-native drivers are available, the last option is almost

always to export data in some sort of a text format.

In order for MS Access to import text data into rows and columns,

there must be some indicators in the text file to separate columns of

data and rows of data. There are two file types.

Delimited Text File

Each record is on a separate line in the text file, and the individual

elements are separated by a delimiter. In MS Access, you can have the

following delimiters:

Comma, Tab, Semicolon, Space

Furthermore, you can also specify a custom delimiter in MS Access.

42

Page 51: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

Delimited Text File

Fixed-Width Text File

There is also one record per line, however, fields are not separated by

any special characters.

Each data element has a fixed width, if the content of the element is

not long enough it is padded with trailing spaces.

43

Page 52: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

44

Page 53: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

45

Page 54: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

46

Page 55: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

47

Page 56: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

48

Page 57: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

49

Page 58: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

50

Page 59: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

4.4 IMPORTING TEXT FILES

51

Page 60: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Exporting MS Access Data

5.

Page 61: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.1 OVERVIEW OF EXPORTING DATA

Exporting data is very similar to importing data. You basically go

through the same steps as with importing data.

Particular consideration must be given to the formatting of data as this

may or may not be exported out.

First of all, besides table data you can also export resulting data from

a query into any of the supported file formats including ODBC

databases.

When exporting to another

Access database, you can

in addition export all other

Access main objects, such

as queries, forms, reports,

macros, and code modules.

52

Page 62: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.1 OVERVIEW OF EXPORTING DATA

There are some differences compared to the import file formats, i.e.

Word Merge file format (delimited text file using tab delimiter).

You can also send out an e-mail attaching the selected data (either

table or query). Default e-mail program must be installed.

The following file formats are

supported natively by MS Access:

Three options when exporting:

Export data with formatting and layout.

Open the destination file after the

export operation is complete.

Export only selected records.

53

Page 63: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.1 OVERVIEW OF EXPORTING DATA

When you export data, you have to understand the export takes place

at the database level. Certain properties in table and query design are

not part of the database, they are part of the application layer part in

Access.

A good example is the format

property. The database does not

know anything about this

property, it will export only the

actual data.

Input Mask: Store mask in

database or not, if stored then it

is exported.

You can use functions to convert

and/or format data before you export it, this way you have control

exactly what data is exported and how it is formatted.

54

Page 64: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.2 EXPORTING DATA

55

Page 65: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.2 EXPORTING DATA

56

Page 66: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.2 EXPORTING DATA

57

Page 67: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

5.2 EXPORTING DATA

58

Page 68: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

Linking MS Access Tables

6.

Page 69: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.1 OVERVIEW OF LINKING DATA

Besides linking other file format-based tables into an Access

database, you can also link an Access table or tables to another

Access database.

Why not import other Access data into the same file? Reasons for

splitting Access databases:

One reason might be that one Access application resides in a different location,

such as a network drive where users can access it.

Another reason might be file size, an Access database can be up to 2GB in size.

The last reason is probably the most common, and that is to create a multi-user

application.

MS Access is a file-based database product, meaning it cannot split its

CPU processing tasks across different physical computers.

You can split database files and link tables into an Access database,

but the processing tasks are executed in the CPU on the computer

where you are running MS Access.

59

Page 70: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.2 ARCHITECTURE OF MULTI-USER ACCESS APPS

Split Access into two components:

Front-end: The application

interface of the database

application, mainly forms,

reports and navigation.

Back-end: The database

tables.

The front-end file contains

the linked tables that point

to the tables in the

back-end file.

The front-end contains

queries, forms, reports, and modules. Furthermore, the front could

also include tables, such as lookup tables where data is not changed.

The back-end data database contains only tables and the established

relationships.

60

Page 71: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.2 ARCHITECTURE OF MULTI-USER ACCESS APPS

If MS Access is run on a client computer, all the CPU processing is

performed on that computer.

For example, running a query against a table with 100,000 records

with a criterion limiting the number of records to 10 still requires the

entire table to be moved over the network (a file is served to the client)

to the client where the query is processed.

Client/server databases process database task on a database server

and send the result to the client (in this example only 10 records),

which results in a dramatic reduction of network traffic.

The main benefits of splitting MS Access databases are:

Sharing data over a network server, thereby creating a multi-user application

Many users can update data at the same time

Updating the front-end part is much easier because the data back-end remains

untouched.

61

Page 72: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.3 SPLITTING AN ACCESS DATABASE

To create a multi-user application, the transaction tables must be

moved to a separate Access database *.accdb file.

Database Splitter Tool

You can also manually

perform the splitting of

a database into a

front-end and a back-end:

Create a new, blank database in MS Access and name it MyApp_be.accdb.

Copy initial database into MyApp_fe.accdb (that automatically preserves the

initial file).

Import transaction tables from MyApp_fe.accdb into MyApp_be.accdb.

Delete all transaction tables in MyApp_fe.accdb.

Link all transaction tables from MyApp_be.acdb into MyApp_fe.accdb.

62

Page 73: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.3 SPLITTING AN ACCESS DATABASE

63

Page 74: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.3 SPLITTING AN ACCESS DATABASE

64

Page 75: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.3 SPLITTING AN ACCESS DATABASE

65

Page 76: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.4 LINKED TABLE MANAGER

Three main purposes:

You can view all your linked tables in one view including the connection

information.

You can refresh linked tables in case the source table’s definition has changed

(columns, indexes, etc.).

You can switch your front-end Access application to a different back-end

database.

Navigate to the External Data tab in

the ribbon, and then click on Linked

Table Manager to access this tool.

You can individually select the linked

table to be updated by clicking in the checkbox, and then click on OK.

Use the buttons Select All or Deselect All to check/uncheck all linked

tables. If the linked table(s) connection is valid, MS Access will display

a dialog box that all table links are refreshed.

66

Page 77: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.4 LINKED TABLE MANAGER

Refreshed Linked Tables Confirmation

There are three possible scenarios when a link to an external data

source is not valid anymore:

Database/file was moved to a different location, but table names have not

changed.

Database/file is in original location but individual table name has changed.

Database/file name has changed.

For invalid linked tables, the

File Open Dialog box is displayed

automatically.

67

Page 78: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.4 LINKED TABLE MANAGER

Note that the title bar of this dialog box contains the table name

currently being selected and in the process of being refreshed.

Select the table and click on Open. After successfully refreshing the

linked table, the confirmation dialog box is displayed.

To switch linked tables to a different location, even though the current

link is valid, select the checkbox at the bottom of the Linked Table

Manager dialog box named “Always prompt for a new location”.

Development front-end

is linked to test back-end

data.

When front-end is moved

to production, point to

production back-end.

68

Page 79: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.5 SETTING UP MULTI-USER APPLICATIONS

69

Page 80: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.5 SETTING UP MULTI-USER APPLICATIONS

70

Page 81: DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ... · DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, ... prototype forms/reports, ... follow these basic

6.5 SETTING UP MULTI-USER APPLICATIONS

71