Reputation:
Is there any way to run a query using VBA without is opening? Currently the code I'm using is:
DoCmd.OpenQuery "qryAvailableCarpenters" 'Sorts the carpenters according to their jobs
DoCmd.Close acQuery, "qryAvailableCarpenters"
DoCmd.OpenQuery "qryPermanentCarpenters" 'Sorts the supervising carpenters according to their number of supervisions
DoCmd.Close acQuery, "qryPermanentCarpenters"
DoCmd.RefreshRecord 'Enables the changes in sorting to be reflected in the combo box
This works but you still see a flash of the queries opening then closing. Is there a way I can change that?
Upvotes: 0
Views: 13627
Reputation: 696
You can use currentdb.execute "qryAvailableCarpenters"
Why are you doing this though? You should simply be able to specify an ORDER BY
clause whenever you access the data. You order it however you wish when you retrieve the data, whether it be for form, report, or datasheet.
Upvotes: 1