Lab 13: More Microsoft Access and Relational
Databases
.pdf version of this document
Reading
for Lab:
·
Review Chapter 20 of Fluency
with Information Technology: Foundations
and Fundamentals of Information Technology
Create a Form using the Form Wizard
Creating a Form Using Design View
Displaying Data from One Table to
Help Add Data to Another:
Adding Instances to tblStudent
Introduction:
In today’s lab we will look at the presentation layer: creating forms for users to input data and receive data output. (See the previous Lab for a brief description of all three levels involved in a complete Relational Database Management System)
Presentation
Services
The interfaces
created to allow users of the Database system the ability to enter data and to
view output of data. A Form is
the typical interface used for input and output of data that is retrieved by a
Query. There are other interfaces in
Access such as Reports and Data Access Pages, but you will only be dealing with
Forms for the first part of Project 3.
Objectives:
TO BEGIN:
1. Download a copy of your database (.mdb file) from the previous lab to the desktop from Dante and open it. [The illustrations below may show the file as Lab15.mdb; use Lab12.mdb or whatever else you actually named the file as in the previous lab.]
If your
database was not closed when you tried to ftp it after the last lab, you will
have an empty file. If this happened,
you will need to work through the previous Lab to recreate it.
Working With Forms in Access
Today’s lab allows you to work with a familiar object, the Form. In Access forms are used for presentation in
a manner similar to their use in Visual Basic. Both are intended as a way to
present data of some kind to a user in a way that is intuitive and helpful
(although not every form is successful in this endeavor!).
The first form will be created using a wizard. The second
and third will be created just in design view. In addition, you will add combo
boxes on one form in order to view data from two different tables as we add
data to a third.
· Click Next
· Choose a style
·
Click Next
INFO
CSE
BIOL
CHEM
PHYS
SPAN
ART
HIST
· Right click on the form title bar, select Properties
· Make sure the Form object is selected in the window
· Select as the record source the Advisor table from the list.
· Go to View>Fields List on the Menu bar
4. Manipulate field properties in Design View
Mel Oyler from Informatics
Alan Borning from Engineering
John Cusak from Art
Vitoli Demetrio from Modern History
Garbonzo Bean from Physics
Go to the Advisor table. Look at the records you just added through
the data entry form.
Now we’ll do something a little
different: create a form that adds data
to the Student table, but it will display data from Major and Advisor
tables.
Once you place the combo box control on your form, a
combo box wizard window will come up to walk you through the process. Select the following options from each screen and then
click Next: You will return to design view. There is now a combo box and label in
the form. The label can be deleted
(the combo box should line up across from the other Major label and text
box).
· Have the combo box look up values from a table
· Select the tblAdvisor as the table that will provide values for the combo box.
· Move ONLY the AdvisorID, Lname and Department from the available fields over to the selected fields window.
· Make sure the “Hide key column” box is checked
· Store the value in the “AdvisorID” field of the Student table (those are the options in the drop down menu)
· Ignore the name option for the combo box and click Finish.
We have set up the combo box so that it displays the text values for us to see, but it will store the corresponding key value in the Student table in the attribute AdvisorID. That stored value will be referred to as a foreign key in the Student table.
6.
Add a List Box to the Form
Once you place the list box control on your form, a
wizard window will come up to walk you through the process. Select the following options from each screen and then
click Next: You will return to design view. There is now a list box and label in the
form.
***A quick note about file
size:*** As you start working on your project, you will create
forms. You will make mistakes and
decide to delete forms and other objects from the database. In other applications, this would usually mean your file
gets a little smaller. It is NOT
that way in Access. Access “remembers” all the different forms and command
buttons, etc that you create - even after you delete them. If you don’t occasionally do a little
“house cleaning”, your database file will grow immense! To clean up your database and decrease the file size
after you have been working in it for a while, compact and repair the
database: Tools>Database Utilities>Compact and Repair
Database… Do this to keep the database size manageable (or the
turn-in program may have difficulty with it).
8. Close your database and FTP the .mdb file (remember, you created it in the previous Lab) to your Dante account if you don’t already have it on disk. We will use it again for the next lab.
WHEW!!!! You’ve made it through another lab! Only a few more to go!!!!!