Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access - execute a saved query by name in VBA

Tags:

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 
like image 956
tdjfdjdj Avatar asked Mar 29 '12 15:03

tdjfdjdj


People also ask

How do I run a saved query in Access?

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.


1 Answers

You can do it the following way:

DoCmd.OpenQuery "yourQueryName", acViewNormal, acEdit 

OR

CurrentDb.OpenRecordset("yourQueryName") 
like image 52
Taryn Avatar answered Oct 07 '22 17:10

Taryn