Possible to capture the Filter By Form?

G

Guest

Forgive this multi-post, but I am getting no results in the other forum where
I have posted this... perhaps it should have been here from the beginning.

Is it possible to capture the filter being applied to a subform's
SourceObject through the "Filter By Selection" or "Filter By Form" if that
SourceObject is a query?

That is, if I am displaying the query datasheet in the subform control and
the user does a "Filter By Form," can I capture that Filter string for later
use?

TIA
 
C

Christer Hedman

print the property in the immediate window:
?Forms!MainForm.Subform.Form.Filter
 
G

Guest

Thanks for the response Chris.

The problem is that the ...subform.form.filter property is only available if
there is a form set as the SourceObject of the subform object. I have a query
set as the Source Object, so the line you suggested gives me an error,
"expression contains an invalid reference to the property Filter."

I actually got an answer on this from another forum. If I set a querydef
object equal to the query that is the current SourceObject of the subform,
then I can use the language:

strfilter = qd.properties("Filter")

....to get the Filter string. I can test to see if the filter is actually
being applied by testing the main form's FilterOn property. One caveat is
that I have to save the query before I try to access the filter, because
otherwise the new filter that the user is applying is not saved and is not
accessible.
 

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