Polytechnic University of The Philippines
Polytechnic University of The Philippines
INFORMATION MANAGEMENT
MS Access
Laboratory Manual
BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY 2-1
SUBMITTED BY:
EXERCISE 1
Open the Bookstore database and modify the database to accommodate the following:
EXERCISE 3
1. On the Objects bar, double-click the Super Bowl table to open it in the
Datasheet view.
2. The data has to be Sorted. Click anywhere in the Year field, then click
the Descending Sort button to display the most recent Super Bowl first.
3. Select the Winner in any year that the AFC won. Click the Filter by Selection
button to display only those records (the years in which the AFC won the game).
4. Click the Remove Filter button. Select any year in which the NFC won, then
click the Filter by Selection button to display the years in which the NFC won.
Remove the filter.
5. Create one additional filter (for example, the years in which your favorite team
won the big game).
CREATING A TABLE
EXERCISE 4
STEP 1 : Create a New Database
● Click the Start button to display the Start menu. Click the Programs menu, then
click Microsoft Access to start the program.
● You should see the Microsoft Access dialog box as shown on the left side. Click
the option button to create a new database using a Blank Access Database.
Click OK.
● Click the drop-down arrow on the Save in: list box. Click the appropriate drive
(drive C or drive A), depending on the location of your data. Double click the
Exploring Access folder to make it the active folder.
● Click in the File Name text box and drag to select db1. Type My First Database
as the name of the database you will create. Click the Create button.
STEP 2 : Create the Table
● The database window for My First Database should appear on your monitor. The
Tables button is selected by default.
● Click and drag an edge or border of the Database window to change its size.
Click and drag the title bar of the Database window to change its position on the
desktop.
● Click the New button to display the New Table dialog box. Click (select) Table
Wizard in the New Table dialog box, then click OK to start the Table Wizard.
CREATING A FORM
EXERCISE 5
STEP 1 : Open the Existing Database & The Form Wizard
● Start Access. Select My First Database from the list of recently opened
databases, then click OK.
● Click the Forms button in the Database window. Click the New command button
to display the New Form dialog box.
● Click Form Wizard in the list box. Click the drop-down arrow to display the
available tables and queries in the database on which the form can be based.
● You should see the dialog box which displays all of the fields in the Students
table. Click the >> button to enter all of the fields in the table on the form. Click
the Next command button.
● The Columnar layout is already selected. Click the Next command button.
● Click Industrial as the style for your form. Click the Next command button.
● The Form Wizard asks you for the title of the form and what you want to do next.
• The Form Wizard suggests Students as the title of the form. Keep this entry.
• Click the option button to Modify the form’s design.
● Click the Finish command button to display the form in Design view.
STEP 3 : Move the Controls
● If necessary, click the Maximize button so that the form takes the entire screen.
The Form Wizard has arranged the controls in columnar format, but you need to
rearrange the controls.
● Click the LastName control to select the control and display the sizing handles.
(Be sure to select the text box and not the attached label.) Click and drag the
border of the control (the pointer changes to a hand) so that the LastName
control is on the same line control. Use the grid to space and align the controls.
● Click and drag the Address control under as the FirstName the FirstName
control. Click and drag the border of the form to 18 cm. so that the City, State,
and PostalCode controls will fit on the same line.
● Click and drag the State control so that it is next to the City control, then click and
drag the PostalCode control so that it is on the same line as the other two. Press
and hold the Shift key as you click the City, State, and PostalCode controls to
select all three, then click and drag the selected controls under the Address
control.
● Place the controls for PhoneNumber, BirthDate, and Gender on the same line .
Move the controls under same line City, State, and PostalCode. Place the
controls for Credits and Points on the . Move the controls under PhoneNumber.
● Fine-tune the form as necessary to make it more attractive. Move LastName to
align it with State. Also you may make the SSN and PostalCode controls smaller.
Pull down the File menu and click Save to save the form.
STEP 4 : Add a Calculated Control (GPA)
● Click the Text box tool in the Toolbox. The mouse pointer changes to a tiny
crosshair with a text box attached.
● Click and drag in the form where you want the text box (the GPA control) to go.
Release the mouse. You will see an Unbound control and an attached label
containing a field number ( for ex. Text24).
● Click in the text box of the control. The word Unbound will disappear, and you
can enter an expression = [Points]/[Credits] to calculate a student’s GPA. Do not
be concerned if you cannot see the entire entry as scrolling will take place as
necessary. You must enter the field names exactly as they were defined in the
table.
● Select the attached label (Text24), then click and drag to select the text in the
attached label. Type GPA as the label for this control and press enter. Size the
text box appropriately for GPA. Size the bound control as well. Move either
control as necessary. Click the Save button.
● If necessary, click and drag the right border of the form so that all controls are
fully visible. Do not exceed a width of 20 cm. for the entire form.
● Pull down the File menu. Click Page Setup to display the Page Setup dialog box.
If necessary, click the Margins tab. Change the left and right margins to 25 mm.
Click OK to accept the settings and close the Page Setup dialog box.
CREATING A REPORT
Exercise 7:
● Click and drag to select Miami (the current value in the Location field). Type
Orlando and press the Tab key. Enter the corresponding values for the other
field: 1000 Kirkman Road, FL, 32801 and (407) 555-55555 for the address, state,
zip code, and office phone, respectively.
● Close the Locations table. You have moved the Miami Office to Orlando.
STEP 5: Point to the CategoryID in one table, and drag it on top of CategoryID in the
other table. Access displays the Edit Relationships dialog box, which lists the fields you
have chosen to relate and offers several options, as shown here:
STEP 6: Click the Enforce Referential Integrity check box, click the other two check
boxes, and then click Create.
Access draws a line representing the one-to-many relationship between the CategoryID
fields in each of the tables.
Tip: When the Cascade Update Related Fields check box is selected, changing a
primary key value in the primary table automatically updates the matching value in all
related records. When the Cascade Delete Related Records check box is selected,
deleting a record in the primary table deletes any related records in the related table.
You can edit or delete a relationship by right clicking the line and clicking the appropriate
command on the shortcut menu.
STEP 7: Close the Relationships window, clicking Yes when prompted to save its layout.
STEP 8: Open the Categories form in Design view.
STEP 9: Maximize the Form window, and drag the Form Footer section selector down
about 2.5 cm to give yourself some room to work.
STEP 10: If the toolbox isn’t displayed, click the Toolbox button .
STEP 11: Make sure the Control Wizards button in the toolbox is active (has a border
around it).
STEP 12: Click the Subform/Subreport button , and drag a rectangle in the lower portion
of the Details section. A white object appears on the form, and the first page of the
Subform Wizard opens.
STEP 13: Leave Use existing Tables and Queries selected, and click Next.
STEP 14: In the Tables/Queries list, click Table:Products.
STEP 15: Add the ProductName, CategoryID, QuantityPerUnit, UnitPrice, and
UnitsInStock fields to the Selected Fields list by clicking each one and then clicking >
button.
Step 16: Then click Next to display this third page of the wizard. Because a field in the
subform is related to a field in the main form (CategoryID), the wizard selects Show
Products for each record in Categories using CategoryID as the Choose from a list
option. Tip: If the wizard can’t figure out which fields are related, it selects the Define my
own option and displays list boxes in which you can specify the fields to be related.
STEP 17: Click Next to accept the default selection, and then click Finish to accept the
default name for the subform and complete the process. Access displays the Categories
form in Design view, with an embedded Products subform. The size and location of the
subform is determined by the original rectangle you dragged on the form.
STEP 18: Adjust the size and location of the objects on your form so that it resembles
the one as follows.
STEP 19: Notice the layout of the subform, and then click View to switch to Form view.
The format of the subform has totally changed. In Design view, it looks like a simple
form, but in Form view, it looks like a datasheet.
STEP 20: Switch back to Design view, make any necessary size adjustments, and if
necessary, open the Properties dialog box.
STEP 21: Click the Form selector in the upper left corner of the subform twice. The first
click selects the Products subform control, and the second click selects the form. A
small black square appears in the button.
STEP 22: On the Format tab of the Properties dialog box, change both Record
Selectors and Navigation Buttons to No. While on this tab, notice the Default View
property, which is set to Datasheet. You might want to return to this property and try the
other options after finishing this exercise.
STEP 23: Switch back to Form view, and drag the dividers between column headers
until you can see all the fields (You can quickly adjust the width of columns to fit their
data by double-clicking the double arrow between column headings).
STEP 24: Click the navigation buttons to scroll through several categories. When you
are through, click the First Record button to return to the first category (Bulbs). As each
category is displayed at the top of the form, the products in that category are listed in
the datasheet in the subform.
STEP 25: Click the category name to the right of the first product. The arrow at the right
end of the box indicates that this is a combo box.
STEP 26: Click the arrow to display the list of categories, and change the category to
Cacti.
STEP 27: Click the Next Record navigation button to move to the next category (Cacti).
You can see that the first product is now included in this category.
STEP 28: Display the list of categories, and restore the first product to the Bulbs
category.
STEP 29: You don’t want people to be able to change a product’s category, so return to
design view. Then in the subform, click the CategoryID combo box control, and press
Delete key. Important: You included the CategoryID field when the wizard created this
subform because it is the field that relates the Categories and Products tables. The
underlying Products table uses a combo box to display the name of the category
instead of its ID number, so that combo box also appears on the subform.
STEP 30: Save the form, then switch back to Form view, and adjust the width of the
subform columns and the size of the Form window.
STEP 31: Close the Categories form, saving your changes to both the form and the
subform. Close the database.
● Access will use the column headings in the Excel workbook as field names in the
access table, provided you check the box indicating that the first row contains
column headings. Click Next.
● Select the option button to store the data in a new table. Click Next.
● You do not need information about the individual fields. Click Next.
● Select the option to choose your own primary key. Click the drop-down arrow on
the list box, and select SSN. Click Next.
● Access indicates that it will import the data to a Clients table. Click The Finish
button, then click OK. The Clients table appears within the Database window.
● Repeat the steps to import the Consultants table into the Investment database
from the Investment Data workbook. Use the ConsultantID field as the primary
key for this table.
STEP 3: Create the Relationship
● Pull down the Tools menu and click the Relationship command.
● Pull down the Relationship menu and click the Show Table command. Click
(select) the Clients table, then click the Add button.
● Double click the Consultants table to add this table to the Relationship window.
Close the Show Table dialog box.
● Click and drag the title bar of each table. Click and drag the bottom border of
each table so that you see all of the fields in each table.
● Click and drag the ConsultantID field in the Consultants table field list to the
ConsultantID field in the Clients field list. You will see the Edit Relationships
dialog box.
● Check the box to Enforce Referential Integrity. Click the Create button to create
the relationship.
● Click the Save button on the Query Design toolbar. Save the query as Assets
Under Management. Click OK.
● Pull down the File menu, click (or point to) Export command to display the Export
Query dialog box. Click the down arrow in the Save as type list box to select
Microsoft Excel 97 2003.
● Select the Investment Data workbook and click the Export All button to save the
query as a worksheet in the Investment Data workbook. Click Yes if asked
whether to replace the file. Close the Query window.
● Click the Tables button. Select the Clients table. Pull down the File menu, Click
the Export command, and change the file type to Microsoft Excel 97-2003. Select
(click) the Investment Data workbook. Click Export. Click Yes if asked whether to
replace the file.
● Export the Consultants table in similar fashion. Exit Access.
STEP 7: View the Excel Workbook
● Click the Start button, click (or point to) the Programs command, then select
Microsoft Excel. Click the Open button, change to the Exploring Access folder,
then open the Investment Data workbook.
● Click the Assets_Under_Management tab to see the worksheet. Format the
worksheet to improve its appearance.
● There are two client worksheets, Clients and Clients1, corresponding to the
original and modified client data. Click the Clients1 tab.
● There are also two consultant worksheets, Consultants and Consultants1. Click
the Consultants1 tab.
● Press and hold down the Ctrl key as you click the tab for each worksheet to
select all five worksheets. Pull down the File menu, click the Page Setup
command. Click the Sheet tab. Check the boxes to print Gridlines and Row and
Column headings. Click OK.
● Click the Print button to print the workbook. Save the workbook. Exit Excel.
● You should see the Link Tables dialog box in Figure. Click the Select All
command button to select all three tables, then click OK.
● The system (briefly) displays a message indicating that it is linking the tables,
after which the tables should appear in the Database window.
● Click the Tables button in the Database window. The arrow next to each table
indicates that the table physically resides in another database. (You may have to
relink the tables if you move the database to another computer.)
STEP 3: Import the About Sports Form
● Pull down the File menu, click the Get External Data command, and then click
Import to display the Import dialog box. Select the Exploring Access folder, the
folder you have been using throughout the text.
● Scroll (if necessary) until you can select the About Sports database, then click
the Import button to display the Import Objects dialog box in Figure. Click the
Forms button, select the About Sports form, and click OK. The system pauses as
the About Sports form is brought into this database.
● Once the importing is complete, the Database window changes to display the
forms in this database, which now includes the About Sports form. Open the form
in the Design view, then modify its contents to include your name and school.
Save your changes, then close the form.
STEP 4: Start the Switchboard Manager
● Minimize the Database window. Pull down the Tools menu, click the Database
Utilities command, and choose Switchboard Manager.
● Click Yes if you see a message indicating that there is no valid switchboard. You
should see the Switchboard Manager dialog box in Figure.
● Click the Edit command button to display the Edit Switchboard Page dialog box.
Click the New command button to add an item to this page, which in turn displays
the Edit Switchboard Item dialog box.
● Click in the Text list box and type &About Sports, which is the name of the
command as it will appear in the switchboard.
● Click the drop-down arrow on the Command list box. Choose the command to
open the form in either Add or Edit mode (it doesn't matter for this form).
● Click the drop-down arrow in the Form list box and choose About Sports.
● Click OK to create the switchboard item. The Edit Switchboard Item dialog box
closes and the About Sports item appears in the Main Switchboard.
STEP 5: Complete the Switchboard
● Click the New command button in the Edit Switchboard Page dialog box to add a
second item to the switchboard. Once again, you see the Edit Switchboard dialog
box.
● Click in the Text list box and type &Players. Click the drop-down arrow on the
Command list box and choose Open Form in Edit Mode. Click the drop-down
arrow in the Form list box and choose Players.
● Click OK to close the Edit Switchboard Item dialog box. The &Players command
appears as an item on the switchboard.
● Create two additional switchboard items for &Coaches and &Teams in similar
fashion. Your switchboard should contain four items as shown in Figure. Click
Close to close the Edit Switchboard Page dialog box. Click Close to close the
Switchboard Manager dialog box.
● Click the Players button (or use the Alt+P shortcut) to open the Players form.
Click the Maximize button so that the Players form takes the entire window.
STEP 7: Add Your Record
● Click the Add Player button on the bottom of the form (or use the Alt+A shortcut)
to display a blank record where you will enter data for yourself as shown in
Figure.
● Click the text box to enter your first name. (The PlayerlD is an AutoNumber field
that is updated automatically.) Enter your name, then press the Tab key to move
to the next field.
● Continue to enter the appropriate data for yourself, but please assign yourself to
the Comets team. The team is entered via a drop-down list. Type C (the first
letter in Comets) and Comets is entered automatically from the drop-down list for
teams.
● The player rating is a required field (all players are evaluated for ability in order to
balance the teams) and must be A, B, C, or D.
● Click the Action box on the second line, click the drop-down arrow to display the
macro actions, then scroll until you can click the OpenForm action. Click the text
box for the Form Name argument in the lower section of the Macro window.
● Click the drop-down arrow to display the list of existing forms and select
Switchboard (the form you created in the previous exercise).
● Click the Save button to display the Save As dialog box in Figure 1. Type
AutoExec as the macro name and click OK. Click the Run button to run the
macro and open the switchboard.
● Close the switchboard. Close the AutoExec macro.
STEP 2: Create the Prototype Macro
● You should be back in the Database window, which should display the name of
the AutoExec macro. Click the New button to create a second macro.
● Type Ms (the first two letters in the MsgBox action), then press enter to accept
this action. Enter the comment shown in Figure 2.
● Click the text box for the Message argument, then press Shift+F2 to display the
zoom box so that you can see the contents of your entire message. Enter the
message “The object will be implemented in the next version. In the meantime,
you can gain an appreciation for the "look an feel" of the system by stepping
through the various commands on the switchboard” in Figure 2. Click OK.
● Click the text box for the Type argument, click the drop-down arrow to display the
list of message types, and select Information.
● Click in the text box for the Title argument, and enter "Under Development".
● Click the Run button to test the macro. You will see a message indicating that
you have to save the macro. Click Yes to save the macro, type Prototype as the
name of the macro, and click OK.
● You will see a dialog box containing the message you just created. Click OK.
Close the macro.
● Click the text box for the Object Type argument. Click the drop-down arrow and
choose Form as the Object type. Click the Object Name argument, click the
drop-down arrow, and choose Switchboard as the Object (form) name.
● Click the Action box on the third line. Type Cl (the first two letters in Close) and
press enter. Click the comments line for this macro action and enter the comment
shown in the figure. No arguments are necessary.
● Save the macro as Close Database, then close the macro. If necessary, press
the Fll key to return to the Database window, where you should see three
macros: AutoExec, Close Database, and Prototype.
● Select the Report Switchboard, click Edit to open the Edit Switchboard Page
dialog box. Click New to open the Edit Switchboard Item dialog box.
● Add the first switchboard item. Click in the Text list box and type Report 1 as
shown in Figure 4.
● Press the Tab key to move to the Command list box and type the Run M (the first
several letters in Run Macro). Press Tab to move to the Macro list box and type P
(the first letter in the macro name, "Prototype").
● Click OK to create the switchboard item. The Edit Switchboard Item dialog box
closes and Report 1 appears on the Report Switchboard page.
● Add Report 2 as the next switchboard item. Specify the Run macro command
and choose AutoExec as the macro.
● Add an additional item that will return the user to the main switchboard. Click
New to open the Edit Switchboard Item dialog box. Click in the Text list box and
type "&Return to Main Menu..."
● Press the Tab key to move to the Command list box, where the Go to
Switchboard command is entered by default. Press the Tab key to move to the
Switchboard list box, and type M (the first letter in the "Main Switchboard"). Click
OK to create the switchboard item. Close the Edit Switchboard Page.
● The Edit Switchboard Item dialog box closes and "&Report Menu" appears on
the main switchboard.
● The main switchboard needs one last command to close the database. Thus,
click New to open the Edit Switchboard Item dialog box. Type &Exit as the name
of the command.
● Press the Tab key to move to the Command list box and type R (the first letter in
"Run Macro"). Press the Tab key a second time to move to the Macro list box,
and type C (the first letter in the "Close Database" macro). Click OK to create the
switchboard item.
● The main switchboard should contain six items— &About Sports, &Players,
&Coaches, and &Teams from the first exercise, and &Report Menu and &Exit
from this exercise.
● Close the Edit Switchboard Page dialog box. Close the Switchboard Manager.
STEP 6: Test the Main Switchboard
● Click the Restore button in the Database window to view the objects in the
database, click the Forms button, then double click the Switchboard form to open
(Figure 6).
● Click the Exit button (or use the Alt+E shortcut).
● You should see an informational message similar to the one shown in the figure.
(The message is displayed by the MsgBox action in the Close Database macro.)
● Click OK to accept the message. The Close Database macro then closes the
database.
● Pull down the File menu, then click Sports Objects from the list of recently
opened databases. The AutoExec macro executes automatically, maximizes the
current window, and displays the main switchboard.
STEP 7: Test the Report Switchboard
● Click the Report Menu button (or use the Alt+R keyboard shortcut) on the main
switchboard to display the Report switchboard in Figure 7.
● Click the buttons for Report 1, Report 2.
● Click the Return to Main Menu button to exit the Report Menu and return to the
main switchboard.
● To continue working, click the Close button on the title bar (or pull down the File
menu and click the Close command) to close the form and continue working on
this database. (You should not click the Exit command button as that would close
the database.) You should be back in the Database window, where you can
continue with the next hands-on exercise.
● To close the database, click the Exit button (or use the Alt+E shortcut).
● Either way, you have demonstrated the "look and feel" of the system to the extent
that you can step through the various menus. Good work.