Access XP
Filtering Records
Introduction
By the end of this lesson, learners should be able to:
- Perform a Filter By Selection
- Remove a Filter
- Perform a Filter Excluding Selection
- Perform a Filter By Form
Performing a Filter by Selection
At times, you might want to view only those records that match a specific criterion. A filter is a technique that lets you view and work with a subset of data. Applying a filter to an Access table, form, or query temporarily hides records that don't meet your search criteria. For example, you may only want to work with data pertaining to a specific zip code.
To Filter By Selection:
- Click anywhere in the field that you want to filter the records in the table.
- Click the Filter by Selection button in the standard toolbar or choose RecordsFilterFilter By Selection from the menu bar to apply the filtering.
- The filter produces a display that shows only those records that match the filter's definition (e.g., North Carolina). The status area reflects only the filtered records.
Removing a Filter
To Remove a Filter:
- Click the Remove Filter button on the standard toolbar or choose RecordsRemove Filter/Sort from the menu bar.
- The records revert to their ordering before the sort was applied.
- Optional, if you wish to reapply the filter, click the Apply Filter button (This button acts like a toggle to turn the filter on and then turn the filter off).
Saving a Filter
Access defaults to displaying all records in a table. Filters are not applied to the table initially. Filtering table records actually change the table design. When you attempt to close a table after a filter, Access will prompt you to save the changes to the table design.
To save a filter:
- Exit the table.
- Click the Yes button in response to the question, Do you want to save changes to the table?
The filter order is saved.
When you open the table or form later, all the records will be visible. Click the Apply Filter button to reapply the filter. However, Access saves only the last filter you create.
You can apply filters to filtered data to narrow your search even further.
To cancel a filter:
- Exit the table
- Click the No button in response to the question, Do you want to save changes to the table?
The change is not saved; the table remains in its original design.
Performing a Filter Excluding Selection
The Filter Excluding Selection works in the opposite manner as the Filter by Selection. Instead of specifying the filter to be used to view records (e.g., everybody in North Carolina), Filter Excluding allows you to view data that does not include the specified criterion (e.g., everybody not in North Carolina).
To Apply Filter Excluding Selection:
- Click anywhere in the field that is to be excluded from the filter.
- Choose RecordFilter Excluding Selection from the menu bar or right-click and choose Filter Excluding Selection from the shortcut menu.
- All records except the criterion you excluded are now visible.
- The status area shows only the filtered records displayed on the screen.
Remove this filter by clicking the Remove/Apply Filter button.
Performing a Filter By Form
The Filter by Form feature is used when you are working in Form view and not in Datasheet View. Filter by Form works the same way as the Filter by Selection method, except the filtering is defined on a blank contact data entry form as if you were creating a new contact record.
To Filter by Form:
- In Form View or Datasheet View, click the New Record button to create a blank form or datasheet.
- Click the Filter By Form button in the standard toolbar.
- When you click in a field (e.g., State/Province), a drop-down list is opened and displays all the criteria (filter values) available for selection.
- Select a filter value from the drop down list (e.g., North Carolina, to view all records in North Carolina).
- To display records meeting more than one search criteria, click the Or tab located at the bottom of the screen. Otherwise, continue to the next step.
- Click the Apply Filter button to apply the filter and view the filtered records.
Challenge!
- Open the Contacts table in Datasheet View.
- Apply the following Filter by Selection filters:
- Filter by Selection on any record that reveals a State of "North Carolina."
- Filter by Selection on any record that reveals a City of "Cary."
- Remove the filter.
- Apply the following Filter Excluding Selection filters:
- Filter Excluding Selection on any record that reveals a City of "Cary."
- Remove the filter.
- Filter Excluding Selection on any record that reveals a State/Province of "North Carolina."
- Remove the filter.
- Apply the following Filter By Form filters:
- Filter By Form on the City of "Raleigh."
- Remove the filter.
- Close the Contacts table, and if displayed, click the NO button in response to the Do you want to save changes to the design of table 'Contacts' system prompt.