Access Lab1
Access Lab1
* Field Size is located on the General tab at the bottom of the data
structure window you are currently working in.
6. Choose Save from the File menu. If you haven’t already saved the table, in the Save As
dialog box, enter the name Contractors and click OK.
What is a query?
Notes:
• Queries are independent objects just like tables. You use queries to view, change, and
analyze data in different ways. You can also use them as a source of records for forms
and/or reports.
• A form or a report can be based on a table or on a query.
• A query displays a subset of all the fields and records in a table or multiple tables.
• The subset of data displayed by the query is called a dynaset (short for dynamic set).
Example: The following are instructions to create a sample query that displays names and
addresses of contractors who live in the Province of Ontario, sorted alphabetically by name.
c. A field list for the Contractors table is added to the Select Query window
a. Double-click the title bar of the contractor’s field list to select all the fields. Drag
these selected fields (can drag all fields at one time once they are all selected) to the
first Field cell in the Design grid.
b. The fields listed in the Design grid at the bottom of the Select Query window are
those fields that will be displayed for this query. The order of the fields from left to
right in the grid will be the order the information will appear in the query.
4. If you do not want all of these fields to be displayed in the query, you can Delete
unnecessary columns.
b. Click once on the selector box above this column to select it. (The selector box is the
very narrow grey bar above the column name of Notes – the mouse cursor changes to
a down arrow when it hovers above the selector box).
d. Using the same method, delete the Emergencies and the Employee Number
columns.
a. Click and drag over the selector boxes of the Job Category and Hourly Pay
columns
a. To sort the data displayed by the query alphabetically by last name, you must
make Last name the first column of the query.
i. Click the selector box of the Last Name column and release the mouse
button.
ii. Now that the column is selected, click the selection box again, hold down the
mouse button, and drag left to make it the first column.
iii. Note: as you drag the Last Name column, a thick black bar appears to identify
where the column would be placed if you let go of your mouse button.
b. Two cells down from the Field name cell which has “Last Name” in it, there is a Sort
cell. Click once in this cell. Use its drop-down list box to select Ascending.
c. Likewise, select Ascending in the Sort cells for the “First Name” and “Middle
Initial” fields.
ii. In the Criteria cell for the Province field, type ON (ensure upper case).
iii. Click another field, so you can see that Access adds the quotation mark
delimiters around this (text) criterion.
a. Choose Save from the File menu. Access displays the Save As dialog box. As the
Query Name, enter Address List of Contractors from Ontario.
a. Click the Run Query tool (! on toolbar), and after a moment, Access displays the
results of this query.
b. To automatically set all of the column widths, click on the Last Name label and drag
the mouse to the right to select all of the columns. Release the mouse button and
hover the mouse cursor over one of the column boundaries between the labels. The
cursor will turn into a vertical bar with two arrows. Double-click and the columns
will be auto-sized for you.
c. Close the Query window when you are done looking at it. (Say yes to the Save
dialogue.)
* Date tip: If you find that the date is not the same as in this lab exercise, then you may wish
to set the Windows OS preferences. Do this: Start → Control Panel → Regional and
Language Options → Press the Customize button → Select the Date tab → set your
preferences here.
COMPARISON OPERATORS
Operator Meaning
= Is equal to
> Is greater than
>= Is greater than or equal
to
< Is less than
<= Is less than or equal to
<> Is not equal to
LOGICAL OPERATORS
Operator Meaning
AND Both criteria must be true to match
OR Either criterion must be true to match
XOR One of the criteria but not both must be true to
match
NOT The criterion must be untrue to match
Between ... And Finds a range of values