Filter Event

Applies To

Form.

Description

The Filter event occurs when the user does one of the following:

  • Clicks the Filter By Form subcommand of the Filter command on the Records menu, or clicks the Filter By Form button on the toolbar. This opens the Filter By Form window, where you can quickly create a filter based on the fields in the form.
  • Clicks the Advanced Filter/Sort subcommand of the Filter command on the Records menu. This opens the Advanced Filter/Sort window, where you can create complex filters for the form.

Remarks

You can use the Filter event to:

  • Remove any previous filter for the form. To do this, set the Filter property of the form to a zero-length string (" ") in the Filter macro or event procedure. This is especially useful if you want to make sure extraneous criteria do not appear in the new filter. For example, whenever you use the Filter By Selection feature, the criteria you use (the selected text in the form) is added to the Filter property WHERE clause expression, and appears in both the Filter By Form window and the Advanced Filter/Sort window. You can remove this old criteria using the Filter event.
  • Enter default settings for the new filter. To do this, set the Filter property to include these criteria. For example, you may want all filters for a Products form to display only current products (products for which the Discontinued control in the Products form is not selected).
  • Use your own custom filter window instead of one of the Microsoft Access filter windows. When the Filter event occurs, you can open your own custom form and use the entries on this form to set the Filter property and filter the original form. When the user closes this custom form, set the FilterOn property of the original form to True to apply the filter. Canceling the Filter event prevents the Microsoft Access filter window from opening.
  • Prevent certain controls on the form from appearing or being used in the Filter By Form window. If you hide or disable a control in the Filter macro or event procedure, the control is hidden or disabled in the Filter By Form window, and can’t be used to set filter criteria. You can then use the ApplyFilter event to show or enable this control after the filter is applied, or when the filter is removed from the form.

See Also

Filter Property, Filter Property (Microsoft Office 95 Data Access Reference), FilterLookup Property, FilterOn Property, OrderBy Property, OrderByOn Property.