Filtering Data

Filtering is for those times when you want to get many of the records out of the way so you can see the few that you're interested in. Filtering temporarily narrows down the number of records that appear, according to criteria you select.

Filters versus Queries

Queries also narrow down the records displayed, as you'll learn in Lesson 19. A filter is easier and quicker to use than a query, but a filter can't be saved as a separate object for later use. (However, you can save a filter as a query, as you'll learn later in this lesson.)


There are three ways to apply a filter: Filter by Selection, Filter by Form, and Advanced Filter/Sort. The first two are the most common for casual users, so we will cover them in the following sections. The third method is for advanced users only.

Sorting and Filtering

Neither of the filtering methods you'll learn in this lesson allow you to sort at the same time that you filter. However, it's easy enough to sort the filtered records, using the same sorting process you learned earlier in this lesson.


Filter by Selection

Filtering by selection is the easiest method of filtering, but before you can use it, you have to locate an instance of the value you want the filtered records to contain. For example, if you want to find all the dogs in your table that have earned the title of CD (Companion Dog), you must first locate a record that meets that criteria. You'll base the rest of the filter on that record.

To filter by selection, follow these steps:

  1. In a field, find one instance of the value you want all filtered records to contain.

  2. Select the value, as follows:

    • To find all records where the field value is identical to the selected value, select the entire field entry.

    • To find all records where the field begins with the selected value, select part of the field entry beginning with the first character.

    • To find all records where the field contains the selected value at any point, select part of the field entry beginning after the first character.

  3. Click the Filter by Selection button on the toolbar, or select Records, Filter, Filter by Selection. The records that match the criteria you selected appear.

Figure 18.2 shows the Dogs table filtered to show only dogs that have earned the CD title.

Figure 18.2. The result of a filter; only the records that match the criteria appear.


Filtering by More Than One Criteria

With Filter by Selection, you can filter by only one criteria at a time. However, you can apply successive filters after the first one to further narrow the list of matching records.


You can also filter for records that don't contain the selected value. After selecting the value, right-click on it; then select Filter Excluding Selection.

You can cancel a filter by clicking the Remove Filter button (the same as the Apply Filter button), or by selecting Records, Remove Filter/Sort.

Filter by Form

Filtering by form is a more powerful filtering method than filtering by selection. With Filter by Form, you can filter by more than one criteria at a time. You can also set up "or" filters, which find records in which any one of several criteria is matched. You can even enter logical expressions (such as "greater than a certain value").

To filter by form, follow these steps:

  1. In Datasheet or Form view, click the Filter by Form button on the toolbar or select Records, Filter, Filter by Form. A blank form appears, resembling an empty datasheet with a single record line.

  2. Click in the field you want to set a criterion for, and a down-arrow appears for a drop-down list. Click on the arrow, and select the value you want from the list. Or you can type the value directly into the field if you prefer.

  3. Enter as many criteria as you like in various fields. Figure 18.3 shows two criteria, including a criteria that uses a less-than sign, a mathematical operator (explained in Lesson 19).

  4. If you want to set up an "or" condition, click the Or tab at the bottom of the Filter by Form window, and enter the alternate criteria into that form. Notice that another Or tab appears when you fill this one, so you can add multiple "or" conditions.

  5. After you enter your criteria, click the Apply Filter button on the toolbar. Your filtered data appears.

    Figure 18.3. This query finds all dogs that were born before 1/1/93 and have a CD (Companion Dog) title.

As with Filter by Selection, you can undo a filter by clicking the Filter button again or by selecting Records, Remove Filter/Sort.

Saving Your Filtered Data as a Query

Filters are a convenient alternative to creating a simple query from scratch. You can save a filter as a query, and use it as you would use a query; it even appears on your Queries list in the Database window. (You'll learn more about working with queries in Lesson 19.)

To save a filter as a query, follow these steps:

  1. Display the filter in Query by Form view.

  2. Select File, Save As Query or click the Save button on the toolbar. Access asks for a name for the new query.

  3. Type a name and click OK. Access saves the filter.

In this lesson, you learned how to sort and filter your database. In the next lesson, you will begin learning about queries, a more sophisticated way of isolating and organizing information.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.9.115