Microsoft Access 2000 for Windows Handout: 3 Academic Computing Support Information Technology Services Tennessee Technological University December 2001 1. Creating a new database In this exercise, we will create our database from scratch without using a wizard as we did in the first two classes. To begin with, we will create four tables in our database: employee information, a list of departments, asset information, and maintenance information. We will also add a switchboard table to help navigate the database. In the PC labs, from the Start menu: Select Programs g MSOffice 2000 g Microsoft Access Otherwise, from the Start menu: Select Programs g Microsoft Access Select Blank Access database and click OK. In the PC Labs, browse to your U: drive, elsewhere to your C: drive and name the database Assets.mdb Click Create. 2. Creating tables in Design View Under Objects, select Tables Double-click on Create table in Design view OR click on New in the toolbar and select Design View and OK.
Access 2000 Handout 3 Page 2 2. Creating tables in Design View (cont.) The first table will hold information on employees. We will use Social Security number as the employee ID and this will be the primary key for this table. A primary key uniquely identifies each record in a table and can be used to link tables. Enter the first field name: EmployeeID Select the data type: Text From the menu, select Edit g Primary Key Remember that numeric fields are those on which you could do a computation, such as addition or subtraction. Social Security numbers are text fields that consist of numbers. Enter the rest of the fields shown here. Note that the field Description is optional, but can come in handy later when someone else takes over your database or to remind you of your design decisions. In this table, we will use Text, Currency, Date/Time, and Memo field types. Click on the x to close the table. Save it as Employees and click OK. Adding Input Masks It is helpful for some fields to have predefined input masks to guide data entry. Select the table Employees and click on Design in the toolbar. Click on the Field Name EmployeeID Under Field Properties at the bottom of the screen, click into the box Input Mask Then click on the pop-up menu button with three dots. Click Yes when asked to save the table.
Access 2000 Handout 3 Page 3 Adding Input Masks (cont.) Select Social Security Number from the list of predefined masks. Click in the Try It: box to see how it will appear to those doing data entry.. Accept the defaults and click Next and then Finish. Click on the Field Name Phone and follow the same steps to create an input mask for phone number. Formatting Data Display Click on the Field Name DateHired Under Field Properties at the bottom of the screen, click into the box Format From the pulldown menu, select the display format you prefer. Close and save the table. Creating the Departments table Under Objects, select Tables Double-click on Create table in Design view Create the two fields as shown here and save the table as Departments. Open the table and enter these departments (note that the ID is automatically numbered for you). Biology Computer Science English History Mathematics Physics Sociology Then close the Departments table.
Access 2000 Handout 3 Page 4 Adding a Lookup Field to the Employees Table Select the table Employees Click on Design in the toolbar. Under Data Type for the field Department, select Lookup Wizard Select I want the lookup column to look up the values in a table or query. Select the only table listed: Departments and click Next Select both fields and click Next Check the box Hide Key Column and click Next Accept the suggested name, Department, and click Finish When asked to save the table, click yes. Entering Data into the Employees table: From the menu, select View g Datasheet View Enter the following individuals, noting how the masks and lookup menu work. 123-45-6789 987-65-4321 John Doe Sue Smith Mathematics Biology (931) 372-1234 (931) 372-8888 08/20/91 8/15/96 $40,000 $35,000 Close the Employees table. Creating the Assets Table: Under Objects, select Tables Double-click on Create table in Design view Create the fields as shown here. Be sure to set your Primary Key.
Access 2000 Handout 3 Page 5 Creating the Assets Table (cont.) Use the Lookup Wizard for the field EmployeeID to lookup first and last names of employees to whom each asset is assigned. Save the table Enter the following into the Assets table: Close the table Dell Optiplex Dell Dimension GX400 4300 11223344 ABCDEF $1,500 $1,250 John Doe Sue Smith Creating the Maintenance Table Under Objects, select Tables Double-click on Create table in Design view Create the fields as shown here. Be sure to set your Primary Key. Note that the AssetID field is created using the Lookup Wizard and it consists of three fields AssetID, Serial Number, and Description as shown below. Enter this data into the table: 11223344 11/15/01 Possible Virus Disinfected Complete $55 ABCDEF 11/30/01 Printer Problem Installed Drivers Complete $35
Access 2000 Handout 3 Page 6 Enter this data into the table: 11223344 ABCDEF 12/3/01 11/8/01 Lost internet connection Email problem Replace Ethernet card Reinstalled software Not Complete Complete $75 $45 3. Adding a Switchboard From the menu, select Tools g Database Utilities g Switchboard Manager When asked Would you like to create one? Click Yes Edit the main Switchboard as discussed in handout 2 to create two new items: Modify Switchboard and Exit to get the Switchboard started. Click on the Forms button and note that a generic Switchboard Form has been created. To have your database open to the Switchboard: From the menu, select Tools g Startup Under Display Form/Page, select Switchboard and click OK. Close the database and reopen it to see the effect of this change.
Access 2000 Handout 3 Page 7 4. Understanding Relationships We have created several relationships among our tables by using the Lookup Wizard to define some of our fields. To see these relationships in graphical form, from the menu select Tools g Relationships. If needed, drag and move the boxes to get a clear view. It should look something like this. Close the relationships window. 5. Creating a Query to be used as the basis for a Report Under Objects, select Queries Double-click on Create Query in Design View From the list of tables, select Assets, click Add Select Maintenance, click Add Click Close Add the fields to the query as shown below. Close the query and try to name it Maintenance. Notice that you cannot name a query and a table exactly the same. Now name the query: Maintenance Query
Access 2000 Handout 3 Page 8 6. Creating a Report based on a Query Under Objects, select Reports Click on New in the toolbar. Select Report Wizard From the pulldown list, select Maintenance Query. Click OK Select all fields Accept the suggested data view: by Assets
Access 2000 Handout 3 Page 9 6. Creating a Report based on a Query (cont.) Do not add any additional grouping levels. Sort the records by Maintenance Date in ascending order by selecting it in the pulldown menu. Note the Summary button which allows you to add totals (we will do this another way later). Accept the default suggestions for the layout of the report. Select a style, such as Corporate Title the report: Maintenance Click Finish The report should look something like this:
Access 2000 Handout 3 Page 10 7. Editing a Report Created by a Query From the menu, select View g Design View Notice that the report consists of several sections: Report Header: Information that will appear one time at the top of the report Page Header: Information that will appear at the top of each page Description Header: Information that will appear as each description changes (In this case, the Asset Description which we selected in the wizard as the data view). Detail: Each line of detailed information in the report. Page Footer: Information that will appear at the bottom of each page Report Footer: Information that will appear one time at the bottom of the report To modify the label for the Maintenance Date so that we can see it: Click on that label in the Page Header section to select it and drag the box down to increase its size to two lines. In the toolbar, select a centered alignment. Note: you will know an object is selected when it has 8 squares connected by lines around it. Mouse over the line under the heading labels until a hand appears and click and drag the line down below the heading labels. Note: to move an entire box, select the box and move to an edge until a hand appears, click and hold and you can now move the box. Under Detail, drag the Maintenance Date field box to the left to create a size large enough to hold all the information. To view the results of your changes: From the menu, select View g Layout Preview To better line up the headings: From the menu, select View g Design View Under Page Header click on each label while holding the shift key down to select all. From the menu, select Format g Size g To Fit From the menu, select Format g Align g Bottom From the menu, select View g Layout Preview to see your changes. Close the window and save the changes.
Access 2000 Handout 3 Page 11 8. Adding Totals to a Report Under Objects, select Reports Double-click on the Maintenance Report to view it. From the menu, select View g Design View Be sure that the toolbox is in view: From the menu, select View g Toolbox If the box is checked, the toolbox is open in Design view. Mouse over the buttons to see a label describing what each does. Be sure that the Properties box is in view: From the menu, select View g Properties Click on the label in the Report Header which says Maintenance. Click on the tab All in the Properties box and note the various properties of this label. Move the mouse to the bottom of the Report Footer (grey bar) until it becomes a double arrow and then click and drag down to create some space in the footer. Click on the Text box in the Toolbox and draw a box roughly under Cost in the Report Footer Note that two boxes are created: a label box which says Text and a text box marked Unbound. Double-click in the label box and type Grand Total Double-click in the Text box and type =sum([cost]) From the menu, select View g Layout Preview to see the result. From the menu, select View g Design View Click on cost under Details and hold the shift key down and click on the new Sum box. From the menu select Format g Align g Right Click on the Sum box, then click in the Format box under Properties and select Currency. View your results again.
Access 2000 Handout 3 Page 12 9. Adding a Picture and Line to the Report From the menu, select View g Design View From the menu, select Insert g Picture Browse to the location of the graphic: Classfiles on Athena g ITS g Access g Images g TTUlogoNewPurple.gif Drag it to the right side in the Report Header section. Left click on the Line under the Page Header labels, then right-click and select Copy Right-click in the Report Footer section and select Paste. Click on the line (it is near the top of the section and sometimes hard to see) and drag it down to just above the Grand Total Left-click on both lines while holding the shift key down then right-click and from the popup menu select Align g Left From the menu, select View g Layout Preview to see the result which should be similar to below: Close and save changes.
Access 2000 Handout 3 Page 13 10. Adding a Form for Data Entry Under Objects, select Forms Double-click on Create form by using Wizard Select the table Employees and add all fields by using the double arrowhead. Select the Columnar layout and click Next Select a style for the form, such as Standard Accept the title Employees Click Finish Note how Department is a pulldown menu based on entries in the Department table. Add a button to Close the Form From the menu, select View g Design View Drag down at the bottom of the Form Footer to create some space (look for the double arrow to appear and then click and drag). From the toolbox, click on the add Command Button. Draw in a button in the Form Footer In the Wizard, select Form Operations under Categories Select and Close Form under Actions and click Next. Select either text or one of two pictures and click Next Type a name such as Exit Button and click Finish
Access 2000 Handout 3 Page 14 10. Adding a Form for Data Entry (cont.) From the menu, select View g Form View Try the button out and save changes. 11. Add the Form and Report to the Switchboard From the menu, select Window g Main Switchboard Click on Modify Switchboard Create new switchboard pages for Forms and for Reports Edit these pages to add links to the specific form and reports (See Handout 2) Edit the Main Switchboard page to add links to these new pages. Check out your results. Select File g Exit or use the close box in the upper right corner. 12. Getting Help One of the easiest ways to get help with Microsoft Access is the comprehensive online help included with it. From the menu, select Help g Microsoft Access Help Click on the Index tab For instance, to see samples of expressions type in the search box: Examples of expressions g Should you have a question that the online help does not address. There are several books available at your local bookstore that will aid you, such as: Microsoft Access 2000 for Windows for Dummies and various Microsoft reference books.