How do I execute a saved query in MS Access 2007 in VBA?
I do not want to copy and paste the SQL into VBA. I rather just execute the name of the query.
This doesn't work ... VBA can't find the query.
CurrentDb.Execute queryname
You can also run a saved query in Access to view its result set. To do this, select its name from the list of queries shown in the Navigation Pane. Then press the “Enter” key on your keyboard. Alternatively, double-click the name of the query to run from the listing shown in the Navigation Pane.
You can do it the following way:
DoCmd.OpenQuery "yourQueryName", acViewNormal, acEdit
OR
CurrentDb.OpenRecordset("yourQueryName")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With