Filter and query saved after filter by form

U

ubu

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.
 
U

ubu

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.
 
U

ubu

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.
 
Top