Home  Fees/Services  Access Templates  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

DoCmd Examples - Access 2007 VBA
Apply Filter DoCmd

Docmd Macro VBA Example Macro DoCmd Functions



DoCmd AddMenu
DoCmd ApplyFilter
DoCmd CancelEvent
DoCmd Close
DoCmd CopyObject
DoCmd DeleteObject
DoCmd FindRecord
DoCmd FindNext
DoCmd GotoControl
DoCmd HourGlass
DoCmd Min/Max/Restore
DoCmd OpenForm
DoCmd OpenQuery
DoCmd OpenReport
DoCmd OutputTo
DoCmd RunSQL
DoCmd SendObject
DoCmd TransferDatabase
DoCmd TransferText

Create Export Specs



DoCmd ApplyFilter to Tables, Forms or Reports

The Apply Filter method is used the restrict the records show in forms, reports and queries.  The following example demonstrates the Docmd.ApplyFilter command when used to restrict the selection of records by the State field in our combo box.


Here are the syntax and options for the apply filter command:

Access Docmd ApplyFilter Method
FilterName Optional Variant. A string expression that's the valid name of a filter or query in the current database. When using this method to apply a server filter, the FilterName argument must be blank.

WhereCondition Optional Variant. A string expression that's a valid SQL WHERE clause without the word WHERE.

The filter and WHERE condition you apply become the setting of the form's Filter property.

You must include at least one of the two DoCmd.ApplyFilter method arguments. If you enter a value for both arguments, the WhereCondition argument is applied to the filter.

The maximum length of the WhereCondition argument is 32,768 characters.

If you specify the WhereCondition argument and leave the FilterName argument blank, you must include the FilterName argument's comma.

Docmd ApplyFilter Example:
The following example uses the Docmd.ApplyFilter method to display only records that contain the state MD in the State field:

DoCmd.ApplyFilter , "State = 'MD'"

An alternate method is to set the filter property setting of a form directly.  In this example we also use a combo box to select the state:

Form_F_Orders.Form.Filter = "State='" & Me.State_Combo & "'"
Form_F_Orders.Form.Filteron = True

See an example of applying a filter directly to a form:

Recordset Filter in MS Access

Form.Filter = & _ "Store_ID=" & Me.Store_Selection.Column(0) & _ " and year=" & Chr(34) & Me.Year_Selection & Chr(34). Form_F_History_By_Store_Final.Form. ...
www.blueclaw-db.com/dynamic_recordset_filters.htm




Site Search:

Custom Search





Templates, Examples & Case Studies

Order Management Software

Inventory Management System

Interior Design Project Management Solution

Contact Management Database Application

Construction Project Management

Lease Contract Management

Livestock Feed Inventory

CRM/Customer Relationships Management

Order Processing System

PM/Preventive Maintenance

Work Order Software

Real Estate Marketing

Reservations Management

Asbestos Survey Management System

Document Revision Management

HOA Database Template

Loan Processing Management

Student Grant Management Software

Personnel Agency Database

Prescription Assistance Plan Management

Subscription Order Management Software

Corporate Document Management Application



Contact Information

Custom Software Developers
MS Access 2007 2003 2000 All Windows Versions