Note: This is part one of a series of articles on Access ADP projects.
Click to see Part 2
Click to see Part 3
Where and Filter Clause do not work when using DoCmd.OpenForm Statement
One of the issues you will find when working with an Access Data Project, (ADP), is the lack of functionality in the Where and Filter clause of the DoCmd.OpenForm statement, they don’t work with ADPs. There are two techniques you can use to overcome this limitation:
Set The Form’s Record Source Property
On startup or during the course of using the form, you can set the form’s record source property using the OpenArgs argument:
Me.RecordSource = “Select * from MyTable Where ” & Me.OpenArgs
Use ServerFilter Property
Another method is to use the ServerFilter property of the form. On the open event you will need to use the following statements
Me.ServerFilter = “”
Me.ServerFilter = Me.OpenArgs
The first line is needed to reset the property before you set it to something else.
Thanks Juan Soto.
We use an ADP Project and have found that although DoCmd.OpenForm did work, often the ServerFilter property would get stuck to the last filter.
Using OpenArgs appears to have solved this issue.
Glad to hear it worked!
Please keep in mind ADP projects will no longer be available after Access 2007, are you planning to upgrade to Linked tables?