Lab: Access '97 Forms

 

[This lab exercise was created by Evelyn Barry.

If you have any questions or comments, she can be contacted at eb48@andrew.cmu.edu]

 

 

This lab is intended as an introduction to Access Forms. It will cover the basic options and should get you started so you can explore more advanced techniques on your own.

For the purposes of this exercise, we will be using the Northwind database.

 

This exercise is presented in two sections. Start each one as a fresh exercise.

 

I. Forms Wizard

 

Open the Northwind database. You should find it in the Microsoft Office Samples subdirectory.

 

Go to the Forms tab. Do not highlight any of the existing queries. Click on New.

 

Highlight Forms Wizard and click on OK.

 

Under Table/Queries click on the arrow at the far right. This should present a selection list of all the tables and queries for the currently active database. For this exercise we will be using the Table Employees. Highlight the selected table.

 

The box under Available Fields should now display all the fields for the Employees table. Select those fields you want displayed on your form by highlighting them and then clicking on the > symbol. The field name should then appear in the Selected Fields box on the right. Continue to do this until you have selected the following fields.

 

First Name

Last Name

Hire date

Reports to

City

Title

 

These fields can be selected in any order.

 

Click on Next>.

 

Form Wizrd will now ask which layout you prefer. Check the different layouts so you can become familiar with them. Do this with the select button to the left of each type. I recommend that you choose Columnar for your form. It is the most easily modified and will more closely resemble most paper documents you will be trying to use. When you have decided which layout you want, click on Next>.

 

Form Wizard will now ask which style you want. Highlight the different choices to see which you like best. Remember that the more complicated the background is, the more difficult it is for the user to read the text on the screen. In addition, many of the color and background combinations slow down form performance. According to some texts, you can use Colorful 1 or 2, or Stone without slowing performance too much.

 

Choose the background and color carefully. I have discovered that changing it later in the game wipes out all other format settings and you will have to start over with customization at that point. It can be very frustrating.

 

Once you have selected the style, click on Next>.

 

Form Wizard will now ask for a title for your form. For this exercise use your Andrew ID followed by frm1, as in eb48frm1. Leave the other setting for opening the form view for data entry, and click on Finish.

 

You have now created a form. With this form you can view the records in the database or add new ones. Use the box with arrows at the bottom of the screen to scroll through the Employees table and view existing records.

 

If you want to change the form, click on the Design view symbol on the far left of the second toolbar at the top of you screen.

 

There are 3 tool bars to help you with Forms. The Forms Design Toolbar which normally displays as the second toolbar at the top of the screen. The Format Toolbar which allows you to change such things as font, size of print, bold, underline, etc. The other toolbar you will find helpful is the Toolbox Toolbar which allows you to insert labels, textboxes, lines and other symbols onto the form. If these toolbars are not displaying, click on View at the top of the screen. Click on the toolbars you will need.

 

The Design view of forms will display the form in three sections; Header, Body and Footer. You can move the boundaries for the Header and Footer to either eliminate them or make them larger, whichever you prefer. Try making the Header big enough for a title. Then use the Toolbox to create a Label in the Header and put a title at the top of your form. Then create a Footer and add a message at the bottom of the form to issue a warning to the users that the data on the form is confidential.

 

You can rearrange the data fields in the body of the form to suit your taste. Do this by clicking on the field and then using a drag and drop technique to move them. (The drag and drop is active when you see your mouse arrow turn into a hand symbol.) You will notice that the data field and its corresponding label move in unison. Keep this in mind when customizing your screen.

 

Try changing the size and formats of the label and data fields. You can even change the color of the type and the fill color for the boxes if you want.

 

After you are satisfied with the form layout, click on the Form View option at the far left of the Form Design toolbar.

 

Tab through the displayed fields. Does the tab move smoothly from one field to the next, or does it seem to skip around the screen? If it skips around, that is because the tab is following the order of the fields in the Table, not the order of the fields on the Form. You can fix this in the following way.

 

Open the form in Design View. The click on View, then select Tab Order.

 

The Tab Order box will display each data field in their current tab order. What you want to do is rearrange them to match the order they appear on the form you have created. Do this by first highlighting the field to be moved by clicking on the small box to the left of the field name. Once that is done, click and drag that field to its new position. Repeat this for each field that needs to be rearranged in the tab order. When you have finished, click on OK.

 

When you have finished customizing your form, always return to the Forms View to see if the changes you made are what you intended.

 

 

II. AutoForms

 

Now let's go back to the beginning. This time we want to create a Form to display the results of a Query.

 

Naturally, we will have to start by creating a new query. This will be very simple. Go to the Query tab for Access. Do not highlight any of the existing queries and click on new. Choose the Design View option. Add Employees table and close the Show Table box. Select fields for your query as follows:

Column 1 EmployeeID

Column 2 FirstName

Column 3 LastName

Column 4 HomePhone

Column 5 Photo

 

Create a selection parameter. Do this by clicking on Query - Parameters. The parameters box allows you to enter a parameter name and the field type. Type in Employee Number for the parameter name. Click on the box for data type. An arrow will appear on the far right of the field. Click on this to select the data type you need. In this case we want to match Employee Number with EmployeeID in the table, so the parameter data type and the data type for the data field in the table must match. EmployeeID is defined as Autonumber in the Employees table, so you must choose an Integer for the parameter's data type.

 

After you have done this, click on OK.

 

Now we need to set selection criteria for the employee we want to display. In column 1, under EmployeeID, enter [Employee Number] on the Criteria line. This tells Access that you want to display only the record with EmployeeID equal to the parameter Employee Number you will enter at run time. The name of the parameter is enclosed in square brackets because there is a space in the middle of the parameter's name.

 

Now run the query by clicking on the large red exclamation mark at the top of the screen.

 

The system will request an employee number. Choose any number 1 through 8. (There are only 8 or 9 records in the Employees Table for Northwind.)

 

The system should then return a datasheet view of the results of the query.

 

This is not a very interesting display, so let's change it into a Form. We can do that as follows.

 

Save your query. Be sure to give it a name you can recognize later.

 

Close Query and go to Forms. Do not highlight any of the existing forms and click on New.

 

This time we want to choose AutoForm:Columnar. With AutoForm you are required to select a table or query. In this case, we want to select the query we just created. Find it in the list of selections and highlight it.

 

Click on OK.

 

The system will automatically run the query you just named. Enter an employee number. Click on OK.

 

AutoForm will automatically create a form to display the fields produced by the query. You can now customize this form by changing to Design View and modifying the form layout as we did with the first exercise.

 

Note: The Query and Form combination we just created is probably best as an inquiry only. You can use forms to enter new records into databases, but you need to consider edit criteria. Forms rely on the edit criteria, unique key requirements and data integrity established under Table and Relationship definitions. I would suggest that you use your own database (not Northwind) to explore these possibilities.

 

 

Return to Home Page