XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
1
Microsoft Office Access 2003
Tutorial 5 – Enhancing a Table’s Designand Creating Advanced Queries
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
2
Create a Lookup Wizardfield in a table
To make a form easier to use, you will often add aLookup Wizard to the form.
Instead of remembering a particular value, you canpick the value from a list.
This approach insures that you cannot enter aninvalid value.
When you create the Lookup Wizard, you willprovide a list of acceptable values from whichother users will make a selection.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
3
Start the Lookup Wizard process
To start the Lookup Wizard process:
Start Access and open the database to be modified
Open the desired table in Design view
Find the field you want to modify as a Lookup Wizard
Click on the right side of the Data Type text box for thefield, and then click the Lookup Wizard option
The first Lookup Wizard dialog box will appear
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
4
Lookup Wizard dialog box 1
Fig05-01
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
5
Lookup Wizard dialog box 2
Fig05-02
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
6
Lookup Wizard dialog box 3
Fig05-03
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
7
A lookup field in Datasheet view
Fig05-06
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
8
Display related table recordsin a subdatasheet
You can form a relationship between two tablesbased on a common field.
You can display the data from the related table asa subdatasheet in the primary table's datasheet.
To see the subdatasheet, simply click the expandindicator in the row for which you'd like to see thesubdatasheet.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
9
Illustration of a subdatasheet
Fig05-08
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
10
Create an input mask for a table field
Some fields require special characters to make them morereadable. A phone number, for example, often includesparentheses and/or dashes. You can create an input maskthat will display these characters as a predefined format.
This predefined format can be used to enter or display datain a field.
You can set up literal display characters that willautomatically appear in a field. When you provide literaldisplay characters, the user will not need to enter thosecharacters.
The Input Mask Wizard makes it easy for you to create aninput mask.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
11
An input mask for aphone number field
Fig05-10
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
12
Input Mask character descriptions
Fig05-11
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
13
Define data validation criteria
You may want to view only records that match a particularcriteria. You can do this by creating a query that uses apattern match.
You can use the like comparison operator using theasterisk (*), the question mark (?), or the numbersymbol(#). These wildcard characters allow you to createmuch more flexible patterns.
You can also create a List of values match by creating alist of valid values and then using the In comparisonoperator to define a condition with two or more values.The non-matching values select records that do not matchthe criteria specified.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
14
A design grid with apattern match field
Fig05-18
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
15
Use a list of values to expand theselection possibilities
Fig05-20
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
16
Use both the And and Or logicaloperators in the same query
There will be circumstances where you will want to useboth the And and Or logical operators in the same query.
The In operator naturally creates an Or condition. You canalso use the key word Or in the criteria row to create an Orcondition.
Placing two conditions on the same row of the Criteria inthe Query design grid creates an And condition.
Placing two conditions on separate rows in the Querydesign grid creates an Or condition.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
17
Sample design grid with And and Orconditions in the same query
Fig05-23
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
18
The query result for the combineduse of And and Or
Fig05-24
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
19
Create a parameter query
Sometimes when you create a query, you don't knowexactly which records the user might want to see.
To allow flexibility in the query, you can create aparameter query.
The parameter query will prompt the user to enter thevalue they want to use to select records.
Once the user has supplied this information, those recordsthat match the value will be displayed in the querydatasheet.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
20
Defining a parameter query
Fig05-25
Fig05-26
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
21
Creating a Crosstab Query
A crosstab query performs aggregate functioncalculations on the values of one database fieldand displays the results in a spreadsheet format.
An aggregate function performs an arithmeticoperation on selected records in a database.
To access the crosstab query wizard, create a newquery and select the Crosstab Query Wizardoption from the New Query dialog box.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
22
Aggregate Functions
Fig05-29
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
23
The Crosstab Query Wizarddialog box 1
Fig05-31
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
24
The Crosstab Query Wizarddialog box 2
Fig05-32
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
25
The Crosstab query recordset
Fig05-33
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
26
The Find Duplicates Query
The find duplicates query finds duplicate recordsin a table or query.
Locating duplicates helps avert potential problems(assigning two different product numbers to thesame product).
To create a Find Duplicates Query, select the FindDuplicates Query Wizard in the New Query dialogbox when you create a new query.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
27
The Find Duplicates Query
Fig05-34
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
28
The Find Unmatched Query
A find unmatched query is a select query thatfinds all records in a table or query that have norelated records in a second table or query.
You can, for example, find all customers whohave not placed an order.
To create a Find Unmatched Query, select theFind Unmatched Query Wizard in the New Querydialog box when you create a new query.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
29
The Find Unmatched Querydialog box
Fig05-35
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
30
The Top Values Query
This query allows you to limit the number ofrecords that display as a result of a query.
Top Values property
Create a query in design view with the necessaryfields and sorting.  Enter the number of records (orpercentage of records) you want selected in theTop Values text box on the Query Design toolbarand then click the Run button.
XP
Access
New Perspectives onMicrosoft Office Access 2003, Second Edition- Tutorial 5
31
The Top Values Query
Fig05-38