Solved OpenForm using FilterName

Sun_Force

Active member
Local time
Tomorrow, 00:06
Joined
Aug 29, 2020
Messages
396
I have a course in databases and currently am studying vba in MS-Access.

This is from one of our books about the parameters of Docmd.OpenForm method (Not the exact phrase. Just as far as I remember) :

You can use either an existing query or a filter that was saved as a query for FilterName.

But it doesn't give any examples. Most sample codes use the where clause to open a form.
I'm trying to open a form with an exact filter. How can I save a filter as a query?
Or maybe I should ask: How can I use FilterName parameter correctly?

Any link to on-line articles can help too.

Thanks.
 
Hi. I've never used Filter either, but you could try creating a query with the criteria you want and use the name of your query as a filter for your OpenForm method.

Hope that helps...
 
As others have said, for the FilterName parameter, use the name of your saved query.
Arnelgp has shown it with macro, below is similar action using vba.

Private Sub btnOpen_Click()
DoCmd.OpenForm "Table1", acNormal, "QueryAsFilter"
End Sub
 

Users who are viewing this thread

Back
Top Bottom