Click to See Complete Forum and Search --> : Run query from module
lintz
Sep 28th, 2005, 08:15 PM
I've created and save a query within Access and want to run it from within one of my modules. I have searched but can't find how to call it.
Can anyone help?
salvelinus
Sep 29th, 2005, 06:42 AM
DoCmd.OpenQuery "your_queryname_here"
dannymking
Sep 29th, 2005, 07:39 AM
Salvelinus' method is one of many.
If you know the SQL then you can do just.. (This is the more efficient method)
CurrentDb.Execute "SQL String"
or you can pull the SQL from the query and then run it..
CurrentDb.Execute CurrentDb.QueryDefs("Query Name").SQL
As a note always use CurrentDb.Execute in favour of DoCmd.RunSQL, especially when performing action query's as this removes the need to suppress confirmation messages generated by the DoCmd.RunSQL method, and it is more efficient.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.