Table of contents
Collapse the table of content
Expand the table of content

Report.ServerFilter Property (Access)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a report within a Microsoft Access project (.adp) or database. Read/write String.


expression. ServerFilter

expression A variable that represents a Report object.


The ServerFilter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA:

Me.ServerFilter = "Country = 'USA'" 

To set the ServerFilter property, you must first either:

  • Set the property value in the form's property sheet.

  • Set the property in Visual Basic by typing

Forms(0).ServerFilter = "fieldname = value "

Note Setting the ServerFilter property has no effect on the ADO Filter property.

You can use the ServerFilter property to save a filter and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

To apply a saved filter to a form, you can click Apply Server Filter on the toolbar, click Apply Filter/Sort on the Records menu, or use a macro or Visual Basic to set the ServerFilterByForm property to True.

The Apply Server Filter button indicates the state of the ServerFilter and ServerFilterByForm properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Server Filter button appears pressed in.

To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object. In either case, the form opens in the Server Filter By Form window.

You can only remove a server filter by using Visual Basic to set the ServerFilterByForm property to False or clear all filter criteria in the Server Filter By Form window and then click Apply Server Filter.

When the ServerFilter property is set in form Design view, Microsoft Access does not attempt to validate the SQL expression. If the SQL expression is invalid, an error occurs when the filter is applied.


See also


Report Object

© 2018 Microsoft