Presentation on theme: "Microsoft Access A Hands-On Introduction Chapter 4."— Presentation transcript:
Microsoft Access A Hands-On Introduction Chapter 4
2 Linking and Importing data Other Data Access Database Connection LinkingImporting Other Data Access Database Copy
3 Linking and Importing data (Contd.) Linking and importing are two ways of getting access to data from an external source. Think of linking as a connection to data located externally. In other words, you have access to it, however it lives elsewhere. Importing on the other hand is a one time process that physically brings into your database, data that is located in another database. At the end of this one time process, the data is in two places. Which method you use is really determined by what you wish to do with the data.
4 Linking and Importing data (Contd.) Link when: - The data you wish to use must remain in it’s current format in the other location. - The data you wish to use must remain in it’s current format in the other location. - The data is in a Client/Server database. - The data is in a Client/Server database. - The data must remain usable by users with a proprietary software package. - The data must remain usable by users with a proprietary software package. Import when: - The data will only be used in Microsoft Access. - The data will only be used in Microsoft Access. If you are importing from a Microsoft Access database, you have a choice of getting either the data or the data and structure.
5 Importing Data from Excel One of the really neat features of Microsoft Access is the ability to import spreadsheet data. Although Lotus spreadsheets can be imported, we will focus on Excel since like Access, it is a Microsoft product. When importing Excel, you can choose to create a new table or import to an existing table. If creating a new table, it is suggested that you insert a new row one in your spreadsheet which contains the Column Headings for your table. During the import, Access will use the first few data rows of the spreadsheet to determine the data type for the fields which will be created. If Access finds inconsistent data type in any column in the first few rows, it will import that column as Text type.
6 Importing Data from Excel (Contd.) In the main Menu, click on File then click on Get External Data and then click Import. Using the Dialog box provided, locate and select the spreadsheet to be imported.
7 Importing Data from Excel (Contd.) Clicking the Import button will activate the Import Spreadsheet Wizard and has displayed the first six rows of the spreadsheet including your first Column Headings row. The spreadsheet name also appears. If the data looks good, click the Next button.
8 Importing Data from Excel (Contd.) Notice that Access has determined that the first row in the spreadsheet contains Column Headings. If this is correct, click the Next button.
9 Importing Data from Excel (Contd.) Here the Wizard gives us two choices. If your choice is a new table, click Next otherwise click the down arrow in the Dialog box to select the name of the existing table from the choices and then click Next.
10 Importing Data from Excel (Contd.) If you are creating a new table, you can select which fields you wish to import and which you wish to skip. You can also change Field Names here if you wish. When ready, click the Next button.
11 Importing Data from Excel (Contd.) We are almost done at this point, however we should either select a field to serve as a Primary Key or let Access create one. Since I am sure that each row in the spreadsheet contains a unique value in the CustomerID field, I have chosen it as the Primary Key. Clicking the Next button brings us to the final Wizard Dialog.
12 Importing Data from Excel (Contd.) Here I have selected tblCustLastFirst as the new Table name. We also have two choices for selection at the bottom of the dialog if we wish to use them. We are now done and can click the Finish button.
13 Importing Data from Excel (Contd.) After clicking the Finish button, the Informational message box is displayed with the path and filename of our imported spreadsheet. The Database window contains the name of our new table which now has the spreadsheet data.
14 Fixing Import Errors Although importing a spreadsheet using the Wizard looks simple enough, there are occasions where you will encounter errors. For instance, if Access finds duplicates in the Primary Key column, it will not create the Primary Key although it will import the data. You will need to fix the problem and then define the Primary Key yourself. If you get data conversion errors, Access will notify you with a message box after the import is finished. An Import Errors table will also be created which will contain a record for each error. The record contains the error description as well as the input row number where the error occurred.
15 External data As you have seen, using data that is located external to your Access database is a straightforward process. Since Access first acquired the ability to import data, the number of different types possible has increased. These types include dBase, Excel, Lotus, Paradox, HTML and others. Since some of these are non-database products but are sometimes used as such, Access is a logical product to switch to. For example, Excel is used by many people as a data storage product and at one time had the distinction of being the number one database product in the world. Even though it is not a database product!
16 Access Forms One of the major benefits of Access is the ability to create and use forms. The main purpose of a form is to act as a user interface. In other words, you build forms to simplify the process of data entry and data modification. Forms are also objects that act as containers for other objects, namely Controls. These Controls are used to impart intelligence to forms and it is this feature that makes forms so useful to users. Most forms are based on tables or queries to provide the data that the user works with. A forms functionality comes from its ability to respond to events.
17 Access Forms (Contd.) This is the Orders form from the Nwind database. The data for the form comes from a query designed specifically for this form. The query provides data from two tables, the Customers table and the Orders table. Remember, the data for a form can come from either a table or a query. A query was used here because the data needed was located in more than one table.
18 Access Forms (Contd.) Controls on the form respond to user events. For example, the Print Invoice button when clicked might run a Macro that was designed to print an Invoice on a network printer. The Combo Box in the upper left next to the Bill To Label, allows the user to change Customers. Controls
19 Events An event is an action that is recognized by a form or control. Forms as well as most Controls in Access have a predefined set of Events. Examples include Keyboard press and release events, Mouse click and move events, events from other controls, System events. In event-driven applications, a user action or system event executes an event procedure. This is the essence of GUIs and event-driven applications. The user is in charge, and your application responds. Almost all Windows applications work this way.
20 Form Functionality A forms functionality is due to its ability to respond to events. - When the form is first opened, the data from the query or table is displayed in controls that you placed on the form for that purpose when you designed it. - When the form is first opened, the data from the query or table is displayed in controls that you placed on the form for that purpose when you designed it. - The user then will take some action such as clicking a Command Button or clicking on a Text Box to change some data. These actions create events. - The user then will take some action such as clicking a Command Button or clicking on a Text Box to change some data. These actions create events. - What your form does in response to these events determines its functionality. - What your form does in response to these events determines its functionality. Click Click and Change
21 Friendly Interfaces Would you like to work with this form for several hours daily? Remember that your users will judge your system on it’s interface, not the plumbing underneath. This form is not well organized and it is obvious that little or no time was spent in its design. It is a very good idea to involve your users in the design of your interfaces since it is they who will be using them. The bottom line is: Keep them simple. Inconsistent Fonts Clash of Colors Haphazard Control Grouping
22 Interface Tips If the interface is replacing a paper form, make it similar. Follow the design standards of other products you have used such as Microsoft Office. Be careful not to get carried away with colors. Grey is softer and therefore easier on the eyes. Be consistent with fonts and font sizes. All controls on a given form should use the same font. Group similar controls together and by functionality. Make sure the flow of the form is Left to Right / Top Down. Leave ample white space so that the form is not crowded. Use Alt Keys on Command Buttons to minimize Mouse usage. Above all, be consistent from form to form.
23 Form Wizards Microsoft Access provides several methods to create forms. The AutoForm Wizard is the fastest way as you simply select the table or query and it does the rest. - The AutoForm is created by simply clicking a Toolbar button while in Datasheet view. - The AutoForm is created by simply clicking a Toolbar button while in Datasheet view. - It uses all the fields from the table or query. - It uses all the fields from the table or query. - It creates a columnar form. - It creates a columnar form. - It provides the form with data from one row at a time. - It provides the form with data from one row at a time. - It does not prompt for any information. - It does not prompt for any information. - It assumes you want a basic form. - It assumes you want a basic form. After creating an AutoForm, you may use the Design Window to tweak it if you wish.
24 Form Wizards (Contd.) This is the Form Wizard selected from the Forms section of the Database window. This is a several step process to build a form by following a series of prompts. 1 2 3
25 What We Have Covered Working with external data. Acquiring spreadsheet data from Microsoft Excel. Interface design with Access forms. Form Controls. Events. What they are and where they come from. Creating forms with Wizards.