Applying a filter to a query with docmd

K

KarenH

I have a listbox that lists stored queries that can be run. User selects one
(gstrQueryNameSelected), next form is displayed showing the entities that are
available on which to run those queries. The filter should be the entity
that they choose from that list strLEFilter).

I have the following code:

DoCmd.OpenQuery gstrQueryNameSelected
DoCmd.ApplyFilter strLEFilter

However when I run it, it opens the query without the filter first, and
after that is closed, runs it again with the filter. These queries take a
huge amount of time to run (extreme amount of data in one table -- I have no
option to change the structure of the data or table, I just need to provide a
way for people to select and run the query). The result of the query are not
being used for any report or form, they merely want the query to show on the
screen (the same as they would if they just double-clicked on the query from
the database window). I could parameterize the query so they would be
prompted for the entity, but they want to be able to select it from a list
instead.

Perhaps I'm not understanding the "ApplyFilter" concept, but it seems wrong
that one would have to first execute and open the query, and THEN open it
again with a filter.

What am I doing wrong? Is there a better way to do this?

Thnks in advance!
 

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