MS Access

Creating an Advanced Filter

The most powerful filter is the . The is so powerful that you can think of it as a baby query. In fact, the procedure for creating an Advanced Filter is virtually the same as it is for creating a simple query. The problem with Advanced Filters is that they can be difficult to set up the first few times especially if you're new to Access.

The Filter window.

A close-up of the Design grid.

Advanced Filters have many advantages. They have the ability to:

  • Sort by multiple fields: You can sort records using several fields. For example, you could sort a table alphabetically by last name and then by first name.

  • Use complex filter criteria and expressions: You can use advanced expressions and operators to search for data. For example you could filter for dates that fall Between 1/1/95 And 12/31/99.

  • Use multiple : You can use more than one criterion to sift through records. For example, you could filter for employees who are from Washington AND who have been with the company for more than five years.

This lesson explains how to get your own Advanced Filters up and running.

  1. If it isn't already open, find and open the Employees table.

    Here's how to create an Advanced Filter/Sort:

  2. Select Records » Filter » Advanced Filter/Sort from the menu.

    The Filter window appears, as shown in figure. The Advanced Filter will probably contain criteria from a previous filter that will have to be removed.

  3. Click the Clear Grid button on the toolbar to clear the grid of any preexisting criteria.

    You're ready to create your Advanced Filter. Notice in figure that the window is split. The top half contains a box labeled Employees, which displays all the fields in the current table. The bottom half of the screen contains a design grid, which is where the filter information goes.

    The first thing you need to do is select the fields that you want to use in your filter. You can add fields to the design grid in two ways:

    • By double-clicking the field on the field list.

    • By clicking and dragging the field down to the design grid yourself.

    Because the field list doesn't have a lot of room, you will usually need to use the field list's scroll bar to scroll up or down the list.

  4. Double-click the LastName field in the field list.

    Access adds the Last Name field to the design grid.

  5. Double-click the FirstName, City, HireDate, and Region fields to add them to the design grid as well.

    You can use any field on the design grid to sort or filter the table. To sort by a field, click the Sort row in the column that contains the field that you want to sort and select Ascending or Descending from the list.

  6. Click the LastName column's Sort row and select Ascending from the drop-down list.

    This will sort the table by the LastName field in Ascending order. You can also sort by more than one field. For example, you could sort by LastName and then by FirstName. When you use several fields to sort a table, Access performs the sort in the order the fields appear in the design grid.

  7. Click the FirstName column's Sort row and select Ascending.

    Next you need to specify the criteria for the Advanced Filter. You type the criteria in the design grid's Criteria row.

  8. Click the City column's Criteria row and typeLondon.

    If you specify more than one criterion on the same Criteria row, Access treats it as an AND criteria statement, meaning a record must match all the criteria in order to be displayed. For example, you could filter for employees who are from Washington AND who were hired after January 1, 1993.

  9. Click the HireDate column's Criteria row and type>1/1/93.

    This criteria will display only records whose HireDate is greater than, or after, 1/1/93. Because it's on the same Criteria row as the City field's "London" criteria, the filter will display only those records whose City field equals "London" and whose Hire Date is after 1/1/93.

    If you specify filter criterion on the Or rows, Access treats it as an OR criteria statement, meaning a record has to match the criterion on one row or the other to be displayed. For example you could filter for employees from California OR Minnesota.

  10. Click the Region column's Or row and typeWA.

    Your completed design grid should look similar to the one shown in figure. You're ready to try the Advanced Filter.

  11. Click the Apply Filter button on the toolbar to apply the filter.

    The Advanced Filter window closes, and Access applies the filter and displays the records that meet your criteria.

  12. Click the Remove Filter button to remove the filter.

To create an advanced filter:

  1. select records » filter » advanced filter/sort from the menu.

  2. double-click each field you want to include from the field list.

    or...

    drag the field from the field list onto the design grid.

  3. in the design grid, enter any desired search criteria for the field in the criteria row.

  4. click the sort box list arrow for the field and select a sort order (optional).

  5. click the apply filter button on the toolbar.

by BrainBellupdated
Advertisement: