Microsoft Access 2002 for Windows Handout: 2 Academic Computing Support Information Technology Services Tennessee Technological University February 2004 1. Opening the File In the PC labs, from the Start menu: Select All Programs MSOffice XP Microsoft Access In the task pane on the right, double click on Assets.mdb Or from the menu, select File Open Navigate to the location that you saved the file in the last class: on the U: drive in the PC Labs Or in the PC Labs, copy the file from ClassFiles on Athena > ITS > Access > Assets.mdb to your U: drive (My Documents). 2. Find Duplicates Query Click on the Queries button under Objects Select Create query by using wizard in the listed options. Click on New in the toolbar at the top of the window. In the New Query window: Choose Find Duplicates Query Wizard Click OK. Select the table: Employees. Select the fields: LastName, FirstName. Select the additional query fields: EmployeeID, Department, Phone. Accept the suggested name Click Finish. View the results. This report is very useful for cleaning data.
Access 2002 - Handout 2 Page 2 3. Date Queries Double-click Create query in Design View The Show Table window will appear. Select Employees Click Add and then Close. Include the fields: LastName, FirstName, DateHired, and Salary. Sort on DateHired Ascending Set the date criteria to find those hired in the 1990s: Between #1/1/90# And #12/31/99# View in datasheet view Save as Hired in the 1990s Query. 4. Parameter Queries Right click on the Hired in the 1990s Query Select Copy from the popup menu. Right click in blank space Select Paste from the popup menu. Name the Query: Select Dates Hired Select the query and click on Design Edit the criteria to include a prompt for the beginning and ending dates. These prompts must be in square brackets: Between [Enter Beginning Date:] And [Enter Ending Date:] View in Datasheet view and note that you are asked to enter the range of dates desired. Close and save the query. 5. Adding a Switchboard If you want others to be able to easily use your database, the switchboard interface may be useful to you. Create a Switchboard From the menu, select Tools Database Utilities Switchboard Manager When asked Would you like to create one? Click Yes
Access 2002 - Handout 2 Page 3 5. Adding a Switchboard (cont.) Edit the Switchboard In the Switchboard Manager window, note that the Main Switchboard page has been created. Now we need to add items to that page. Click Edit. In the Edit Switchboard Page window, click New to create a new item on the page. In the Edit Switchboard Item window, type the text: Modify Switchboard Under Command, select Design Application Click OK In the Edit Switchboard Page window, click New to create another new item on the page. In the Edit Switchboard Item window, type the text: Exit Under Command, select Exit Application Click OK Click Close the Edit Switchboard Page window. Click Close the Switchboard Manager window. View the Switchboard Click on the Forms button under Objects Note that a form named Switchboard has been created. Double click to open the Switchboard form. To have your database open to the Switchboard: From the menu, select Tools Startup Under Display Form/Page, select Switchboard and click OK. Close the database and reopen it to see the effect of this change.
Access 2002 - Handout 2 Page 4 6. Modifying the Switchboard In order to make it easy to use queries, we will add a page to the Switchboard. In the Switchboard, select Modify Switchboard Add a new switchboard named Queries In the Switchboard Manager window, click New Type Queries as the name of the new Switchboard Click OK. Add a link to the new switchboard on the main switchboard In the Switchboard Manager window, select Main Switchboard Click Edit In the Edit Switchboard Page window, click New to create a new item on the page. Type Queries as the text that will appear on the main Switchboard Select the command: Go to Switchboard. Select the switchboard named: Queries. Click OK. Select Queries in the list of Items on this Switchboard Click Move Up to move it up above the other items. Click Close, but remain in the Switchboard Manager. Add a link back to the Main switchboard from the Queries switchboard In the Switchboard Manager window, select Queries Click Edit Click New Type Return to Main Switchboard as the text that will appear. Select the Command: Go to Switchboard Select the Switchboard: Main Switchboard Click OK Click Close Click Close Go to the switchboard and try out the new links. Note that we have not yet actually caused a query to be executed or run. To do this we must first create a Macro which will run the query. Then we can select Run Macro as the switchboard command when we create a new switchboard item on the Queries switchboard.
Access 2002 - Handout 2 Page 5 7. Creating a Macro Under Objects, select Macros Click New. In the Macro window, click on the first cell under Action. From the pulldown menu, scroll and choose OpenQuery. At the bottom, click in the Query Name box and select Employees Query. Close the window and click Yes to save the macro. Type a macro name: Employees Phone Numbers Click OK. Click on the Macro Employees Phone Numbers to see it execute the query. Click on New again to add another Macro. Click on the first cell under Action. From the pulldown menu, scroll and choose OpenQuery. At the bottom, click in the Query Name box and select Select Dates Hired Close the window and click Yes to save the macro. Type the macro name: Select Dates Hired Click OK. Adding the Macros to the Queries Switchboard From the menu, select Window Main Switchboard Select Modify Switchboard In the Switchboard Manager Window, select the page Queries Click Edit Click New Enter the text: Employees Phone List Select the command Run Macro Select the Macro Employees Phone Numbers and click OK. Repeat for the Select Dates Hired query. Return to the Main Switchboard and see how it all works together.
Access 2002 - Handout 2 Page 6 8. Underlying Structure of the Switchboard Under Objects, select Tables Double-click on Switchboard Items The switchboard table includes five fields: SwitchboardID Switchboard Number (Main Switchboard is always 1 ) ItemNumber Where the item will appear on it s Switchboard ItemText Name of the Switchboard Button Command What the button will do when pressed Argument Where to go or what to do based to the command given There are 8 Commands allowed for use in the Switchboard. (These are quite flexible since two of them allow us to run a program/command we have created). ID Number Command Description 1 Go To Switchboard Changes the current switchboard to the switchboard number that is in the argument column 2 Open Form in Add Mode Opens the form in the argument column in add mode 3 Open Form in Edit Mode Opens the form in the argument column in edit mode 4 Open Report Opens the report that is in the argument column 5 Design Application Customizes the switchboard 6 Exit Application Closes the current application leaving Access Open 7 Run Macro Runs the macro that is in the argument column 8 Run Code Runs the function that is in the argument column This table could be built here, but the Switchboard Manager is easier to use.
Access 2002 - Handout 2 Page 7 9. Adding a Form for Data Entry Under Objects, select Forms Double-click on Create form by using Wizard Select the table Employees. Add all fields using the double arrows. Select the Columnar layout.. 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 Click on the Design icon. Note that you can drag the fields around to rearrange to suit your needs. If you do, then change the tab order by selecting View Tab Order 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 Command Button. From the menu, select View Toolbox if it is not visible. Draw in a button in the Form Footer In the Wizard, select Form Operations under Categories Select Close Form under Actions and click Next. Select either text or one of two pictures. Type a name such as Exit Button Click Finish Return to Form view and try it out.
Access 2002 - Handout 2 Page 8 10. Creating Asset and Maintenance Data Entry Forms Under Objects, select Forms Double-click on Create form by using Wizard Select the table Assets 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 Assets Click Finish Repeat these steps to create a Maintenance Form 11. Creating Buttons to Navigate Among Data Entry Forms Under Objects, select Forms Select the form Employees. Click on Design in the Toolbar Drag the Detail bar down to create more space Be sure the toolbox is in view (From the menu, View Toolbox) From the toolbox, click on the add Command Button. Draw in a button In the Wizard, select Form Operations under Categories Select Open Form under Actions and click Next. Select the form Assets and click Next Select Open the form and show all records and click Next Select Text and type ADD/EDIT ASSETS Type a name, such as Open Assets Button Click Finish Size the button and select an appropriate font and perhaps a font color. Repeat these steps to create buttons on the Assets form to open the Maintenance Form and to close the form Repeate these steps to create a button on the Maintenance form to close the form.
Access 2002 - Handout 2 Page 9 12. Add the Form to the Switchboard Try to add a Forms Page with the data entry form for Employees, Assets, and Maintenance listed and with a link back to the main switchboard. From the menu, select Window Main Switchboard Click on Modify Switchboard Create a switchboard page for Forms Edit this page to add a link to the specific forms. Add a link to Return to the Main Switchboard. Edit the Main Switchboard page to add a link to this new Forms page. Check out your results.
Access 2002 - Handout 2 Page 10 13. Protecting Your Work from Users The simplest level of security we can add to a database is a password. In order to enable the password, we will need to enter the database in Exclusive use mode. (This means that the database cannot be opened by anyone else at the same time). In the Main Switchboard choose Exit this Database. From the menu, select File Open Select Assets.mdb In the pulldown menu at the botton, select Open Exclusive Once the database is open From the menu, select Tools Security Set Database Password Choose a password and type it twice. Now exit the database and try to reenter it. Note you must provide your password. 14. Exiting Select File Exit or use the close box in the upper right corner or exit from the switchboard. Note: Changes you make to the data in your database are automatically updated as you work. Access only needs to be saved when you make a change to the layout, create a new report, query, etc. If Access needs to save it will ask you if you would like to save your changes when you try to exit.
Access 2002 - Handout 2 Page 11 15. 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 Microsoft Access Help For example, click on the Answer Wizard tab and type examples of expressions to find information on this topic. Should you have a question that the online help does not address, please contact the Microcomputer Support Office: MicroSupport@tntech.edu Students may call the Helpdesk at 372-3975 or get assistance in the PC labs in person. Handouts on using other programs are available on the web under ITS Documentation: http://www.tntech.edu/its/pubs/