O
OneTwoRomeo
I have a main form with a subform called "DynamicQuerySub". There is a
combo-box on the main form listing queries that the user can pick from. The
query selected is then set as the SourceObject for the subform. I also have a
button which exports the SourceObject of the DynamicQuerySub to excel.
What I would like to do is to take into account the functionality of the
"Filter By Selection" and/or "Filter By Form" options. If the user pulls up a
particular query and applies a filter to it to limit the output to a
particular ProductID, for example, I want the output-to-excel to match what
the user is seeing. That is, I want the output to take into account the
filter that the user applied. I do NOT want to output the entire query
dataset.
I know that with Forms that are used as subforms you can use the
"Form.Filter" property to return the filter being applied:
strFilter = Me.DynamicQuerySub.Form.Filter
But that does not work when the source object is a query. Unfortunately, the
source object must be a query, because this needs to be flexible in case of a
new, user-built query that they want to output. I don't want the user to have
to build a subform for every new query.
My question, then, is how do I return or capture the filter being applied to
a query used as the source object in a subform?
Thanks for your help!
combo-box on the main form listing queries that the user can pick from. The
query selected is then set as the SourceObject for the subform. I also have a
button which exports the SourceObject of the DynamicQuerySub to excel.
What I would like to do is to take into account the functionality of the
"Filter By Selection" and/or "Filter By Form" options. If the user pulls up a
particular query and applies a filter to it to limit the output to a
particular ProductID, for example, I want the output-to-excel to match what
the user is seeing. That is, I want the output to take into account the
filter that the user applied. I do NOT want to output the entire query
dataset.
I know that with Forms that are used as subforms you can use the
"Form.Filter" property to return the filter being applied:
strFilter = Me.DynamicQuerySub.Form.Filter
But that does not work when the source object is a query. Unfortunately, the
source object must be a query, because this needs to be flexible in case of a
new, user-built query that they want to output. I don't want the user to have
to build a subform for every new query.
My question, then, is how do I return or capture the filter being applied to
a query used as the source object in a subform?
Thanks for your help!