Database: Queries

A Query is simply a question that is asked of the table or form. By using Access's Query feature, you can create a query that restricts the screen display to selected fields and (if you choose) display only those field values that meet search criteria.

Queries provide the true power in a database system. They enable you to view data from different perspectives, ask questions about data values, and manipulate field values into patterns that help you gain insight about your data.

Before we go on and do a query, we have to add a few things in the table "Customer List". These few things are some more fields, which will be needed to make the Database a bit more proficient.

Initiate Access if not already done so. Using the File menu open the Database file created which is called Customer. This file should be on your floppy disk (from the previous exercise).

When the file is open, you will see the objects window open with the list of available Tables for you to open, in this case there is only one table that you have created so far, "Customer List". Click on the design button. The design view of the table opens. Table in design view allows you to modify a table's structure. We will be adding three fields in the table through the design window. The fields are Address, Paid and Balance.

You can insert fields either between existing fields or after the last created field. Both techniques are illustrated next.

To insert the Address field between the Last and City fields; click the City field row at the extreme left hand corner of the field name box which is also known as the row selector. The entire row should become highlighted.

From the File menu, choose Insert, and click on Rows. Another way is to use the mouse for the shortcut key, and choose Inset Row from the selection. A third option is to click on the icon on the toolbar, which looks like this:

A new blank row appears. Now, simply complete the field parameters as follows:

Click the Field Name cell in the new row to place the insertion point there. Type Address and press Enter. The highlight moves to the Data Type column. Text is the default type. To keep this setting press Enter. In the description column, type in Customers address.

Press F6 or click the Field Size box in the lower section (pane). Delete the default width, type 25 and press Enter. The new field is completed.

Fields can also be added at the end of an existing structure. To add currency fields named Paid and Balance at the end of the field structure, click the blank Field Name cell below Amount in the upper section (pane) to place the insertion point there. Type Paid and press Enter. Click the down arrow button of the Data Type cell, click Currency, and press Enter. In the description column, type in Customer's Payment. Press Enter to move to the Field Name cell of the last row.

Type Balance and press Enter. Click the down arrow button of the Data Type cell, click Currency, and press Enter. Leave the description cell empty.

Click the icon on the top of the toolbar to select Datasheet View. A message will ask whether you want to save your work. Click Yes.

The Customer List table will now appear in the Datasheet View. You will notice that there is a blank column Address, and if you scroll to the end of the Datasheet you will see that the two new currency columns you created are blank as well.

Fill in the Address details as below:

Address

10 Chewings Street

15 Grange Road

123 Belgrave Road

7 North Street

99 Albert Street

 

Fill in the Paid and Balance columns as below:

Paid

Balance

$400.00

$79.90

$50.00

$15.30

$450.75

$0.00

$200.00

$160.55

$200.00

$340.50

 

When finished with insertion of new values, close the table window, by clicking on the X at the top of the window, not the main program (Access) window.

You will now see the object window open on the screen and by default it is open on the Tables Tab, showing the available list of tables in the database. Click on the next Tab at the top marked as Queries. This will take you to another window, which at the moment is blank.

There are three command buttons on the right hand side, two of them are not available at the time. Click on the New button.

Top of the page

To previous page

To next page

To main page