Hide the Query Results

S

Scott Erwin

I have several queries that run when a form is opened. The results of
those queries are displayed in various list boxes on that form. This
is fine. But the query results are also displayed in the datasheet
view as well. I don't want this to happen. Can this be hidden? I
currently do this by using the DoCmd.Close command after each query is
opened. The result is four quick flashes of opening and closing
windows.

Maybe there's a better way?

Thanks
Scott
 
D

Dirk Goldgar

Scott Erwin said:
I have several queries that run when a form is opened. The results of
those queries are displayed in various list boxes on that form. This
is fine. But the query results are also displayed in the datasheet
view as well. I don't want this to happen. Can this be hidden? I
currently do this by using the DoCmd.Close command after each query is
opened. The result is four quick flashes of opening and closing
windows.

Maybe there's a better way?

Maybe I'm mistaken, but tt sounds to me as though you think you have to
open the queries using DoCmd.OpenQuery in order to get at their results
to display them in list boxes. That's not the case. If you have list
boxes with their rowsources set to those queries, you don't need to
explicitly open the queries in datasheet view at all.
 
V

Van T. Dinh

Results of Queries that are being used as the RowSources for the ListBoxes
on the Form are only shown in the ListBoxes. You don't need to "run" these
Queries as Access will automatically retrieve rows using them when the Form
is opened.

If you have the results of these Queries appear separately in DatasheetView,
your VBA code / Macros must have opened them. Just comment out these
statements that open the Queries in DatasheetView if you don't want them.
 
Top