Lesson3.5.Creating an Advanced Filter


Lesson 3.5. Creating an Advanced Filter

Figure 3-8. The Filter window.


Figure 3-9. A close-up of the Design grid.


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 timesespecially if you're new to Access.

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 The Filter window appears, as shown in Figure 3-8. 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 3-8 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 3-9. 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.

QUICK REFERENCE

TO CREATE AN ADVANCED FILTER:

  1. SELECT RECORDS

    DOUBLE-CLICK EACH FIELD YOU WANT TO INCLUDE FROM THE FIELD LIST.

    OR...

    DRAG THE FIELD FROM THE FIELD LIST ONTO THE DESIGN GRID.

  2. IN THE DESIGN GRID, ENTER ANY DESIRED SEARCH CRITERIA FOR THE FIELD IN THE CRITERIA ROW.

  3. CLICK THE SORT BOX LIST ARROW FOR THE FIELD AND SELECT A SORT ORDER (OPTIONAL).

  4. CLICK THE APPLY FILTER BUTTON ON THE TOOLBAR.




CustomGuide Inc - Access 2003 Personal Trainer
Access 2003 Personal Trainer (Personal Trainer (OReilly))
ISBN: 0596009372
EAN: 2147483647
Year: 2005
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net