Filter and query saved after filter by form

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
This is helpful but I'd like to capture both the recordset and filter to
create my own query in code.
 
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.
 
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

Back
Top