HOME | SITEMAP | COMMENTS

Uncle Jim's Web Designs
Development Tools for the Internet and Your Computer


Microsoft Access Tutorial

 

 
Table Relationships Sorting and Filtering Queries

Sorting and Filtering allow you to view records in a table in a different way either by reordering all of the records in the table or view only those records in a table that meet certain criteria that you specify.

[sort buttons]     Sorting

You may want to view the records in a table in a different order than they appear such as sorting by a date or in alphabetical order, for example. Follow these steps to execute a simple sort of records in a table based on the values of one field:

  1. In table view, place the cursor in the column that you want to sort by.
  2. Select Records|Sort|Sort Ascending or Records|Sort|Sort Descending from the menu bar or click the Sort Ascending or Sort Descending buttons on the toolbar.

To sort by more than one column (such as sorting by date and then sorting records with the same date alphabetically), highlight the columns by clicking and dragging the mouse over the field labels and select one of the sort methods stated above.



[Filter by Selection button]    Filter by Selection

This feature will filter records that contain identical data values in a given field such as filtering out all of the records that have the value "Smith" in a name field. To Filter by Selection, place the cursor in the field that you want to filter the other records by and click the Filter by Selection button on the toolbar or select Records|Filter|Filter By Selection from the menu bar. In the example below, the cursor is placed in the City field of the second record that displays the value "Ft. Myers" so the filtered table will show only the records where the city is Ft. Myers.

[sample datasheet]



[Filter by Form button]    Filter by Form

If the table is large, it may be difficult to find the record that contains the value you would like to filter by so using Filter by Form may be advantageous instead. This method creates a blank version of the table with drop-down menus for each field that each contain the values found in the records of that field. Under the default Look for tab of the Filter by Form window, click in the field to enter the filter criteria. To specify an alternate criteria if records may contain one of two specified values, click the Or tab at the bottom of the window and select another criteria from the drop-down menu. More Or tabs will appear after one criteria is set to allow you to add more alternate criteria for the filter. After you have selected all of the criteria you want to filter, click the Apply Filter button [Apply Filter button] on the toolbar.

[Filter by Form]


The following methods can be used to select records based on the record selected by that do not have exactly the same value. Type these formats into the field where the drop-down menu appears instead of selecting an absolute value.

Filter by Form
FormatExplanation
Like "*Street"Selects all records that end with "Street"
<="G"Selects all records that begin with the letters A through G
>1/1/00Selects all dates since 1/1/00
<> 0Selects all records not equal to zero



Saving A Filter

The filtered contents of a table can be saved as a query by selecting File|Save As Query from the menu bar. Enter a name for the query and click OK. The query is now saved within the database.

[Save As Query window]



[Remove a Filter button]    Remove a Filter

To view all records in a table again, click the depressed Apply Filter toggle button on the toolbar.



Table Relationships Sorting and Filtering Queries