Professional Documents
Culture Documents
Lab 02
Lab 02
Lab 02
2.1.1 Objectives
By the end of this laboratory session, you should:
1 Be able to demonstrate the following Microsoft Access skills:
Create forms.
Create queries to extract information from a database.
Create reports.
2 Have taken the following steps in the Video Rentals System development:
Created a new form for entering and editing details of video categories.
Created a menu form from which the user can access other forms(and later reports).
Created a report for displaying member details.
Created a report for displaying overdue rentals.
2.2 Exercises
2.2.1 Creating new forms
During this section, you will create new forms, utilising Microsoft Access wizards. In the previous
session, you explored a Columnar form, which displayed one record at a time. In this section you
will create a Tabular form, which uses a column per field to display multiple records at a time.
Creating a form with the wizard
1. Open your Video rentals System Microsoft Access database (Videostore.mdb) and use the
Form Wizard to create a new form based on the Category table ( Figure 2.1).
2. Use the following information to aid in
your responses to the Wizard:
Include all fields on the form.
Use a Tabular layout.
Use a Standard style.
Use the form title “Category
Details”.
1
Figure 2.1: Initial Category Details form Figure 2.2: Improved Category form
2
Figure 2.3: Adding an unbound control to the Category Details form
3
2.2.3 Querying databases
Microsoft Access offers the ability to create queries that extract, summarise and manipulate data
stored in a database in order to produce information required by the users of the system. For
example, the users of the Video rentals System require a list of all the currently hired videos. A
query can be created to produce such a list.
In this section, you will therefore query the Video rentals System database. Later in the course, you
will look at database queries in more detail.
Current rentals
In this section you will create a query to display all the videos that are currently out on hire along
with their associated borrower (i.e. the member who hired the video). In next week's session this
query will be used as the data source for the video rental form.
1 Open the Video rentals System.
2 Switch to the Queries tab of the database window.
3 Create a new query (without using the wizard) and include the Hire and Video tables.
4 From the two tables add the following fields (refer to Figure 2.5):
Hire: Hire_Num, Member_ID, Video_Code, Issue_Date, Due_Date, and Return_Date
Video: Title and Status.
6. Run the query using the Run toolbar icon . Is the query displaying the correct
information (i.e. only current rentals)?
The Current Rentals query presently displays all hires, whether current or passed. To limit the query
to only the current rentals, it is necessary to apply specific criteria. In this case a hire is current if the
4
video status is false (meaning the video is unavailable) and the hire has no Return_Date (it has not
been returned). Is it necessary to include both these criteria?
7. In the criteria row of the Current Rental query, enter the following criteria for the
Return_Date and Status fields:
Return_Date: Is Null
Status: False
8. Check that the query now displays the correct information.
9. Have a look at what is going on behind the scenes: From the view menu, select SQL view.
How much of the code can you understand? The code you see is known as Structured Query
Language (SQL) - you will be introduced to it in lectures later in the course.
Overdue rentals
Create a query named “Overdue Rentals” which satisfies the following criteria:
Displays the borrower's Member_ID, Surname, First_Name, Title and the video's Title, the
Issue_Date, and Due_Date.
Only displays hires which are currently outstanding (i.e. have a Due_Date that is less that
the current date (<date()).
Uses the query's Sort row to sort the results alphabetically by Surname and First_Name.
Note: It maybe necessary to include other fields in order to satisfy the necessary criteria for the
query.
5
(e) Use the corporate style.
(f) Enter an appropriate title.
4 Switch your report into Design Mode and explore the available options until you have modified
your report to resemble that illustrated in Figure 2.6.
6
1 Use the report wizard, selecting the Overdue Rentals query as the data source.
2 Select only the fields required, as shown in Figure 2.7
3 View the data “by Member”, but note in passing how the report would appear if you selected
“by Hire” or “by Video”.
4 No grouping is required.
5 The videos listed for each member should be listed in alphabetical order of title.
2.2.5 Review
In this week's laboratory session you have:
1 Experienced how a Microsoft Access wizard can rapidly create forms for accessing and
manipulating data stored in tables
2 Explored how forms can make it easy for the user to manipulate data stored in tables
3 Familiarised yourself with the different types of objects that make up a form and how their
properties can be customised to meet the needs of the user
4 Examined how queries can extract information from multiple tables
5 Discovered how reports can be used to present information drawn from tables and queries in a
pleasing useful manner.
End of lab. 2