Filter and query saved after filter by form

G

Guest

Is there any way to capture in code the name and parameters of the query
saved when a
user saves a filter using filter by form?
 
A

Allen Browne

Read the Filter property of the form, e.g.:
Dim strWhere As String

If Me.FilterOn Then
strWhere = Me.Filter
End If

From there, you have to parse the text out.

Note that the form's Filter may contain values from lookup tables that are
not in the RecordSource of the form.
 
G

Guest

This is helpful but I'd like to capture both the recordset and filter to
create my own query in code.
 
A

Allen Browne

What is the RecordSource of the query?
- A table or query? You need:
"SELECT * FROM MyTable WHERE " & strWhere & ";"

- a SQL statement? You need to parse it get the WHERE clause, and AND the
filter.
 
G

Guest

It's an SQL statement I set up using data from 3 tables. I figured out that
all I probably need to do is use the filter as the Where statement on my new
query. It finally dawned on me.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top