# How to call query from VBA



## ishak (May 2, 2005)

Hi everybody! I've created a query from query design view and I want to call it from VBA. Can you shed me some light how to accomplish this?

Another question: please show me how to suppress Dialog box message that comes everytime I run action query to update the table. This is the message: *The existing table XTable will be deleted before you run the query. Do you want to continue anyway?*

Ishak
.............................................................


----------



## OBP (Mar 8, 2005)

Ishak, to call the Query from VBA you obviously need some trigger to run the VBA code.
The actual code is 

docmd.openquery ("QueryName")

where QueryName is the actual name of your Query.
You can add options at the end of the statement that tells Access how you want to open the query. If you type in a comma "," after the Query Name it will give you a list of the options.

The command for turning off system warnings is 

DoCmd.SetWarnings False

don't forget to turn them back on again with 

DoCmd.SetWarnings True

One thing that I am surprised at is the Warning Message, when just updating a Table it does not normally say "table XTable will be deleted", it normally says Some Rows will be updated.


----------



## ishak (May 2, 2005)

Thanx you OBP very much for the reply. Just for clarification, the part of the statement "table XTable will be deleted" is my own words, not from the system.

Thanx

ishak


----------

