Running Queries with code (1 Viewer)

halem2

Registered User.
Local time
Today, 12:43
Joined
Nov 8, 2006
Messages
180
Hi All:

long time no ask! Running MS Access 2003.

I'm trying to run a couple of queries using code and it works fine but when it runs you can actually see the query window open and close really fast.

How can I run it without showing the query window?

This is my simple code

DoCmd.SetWarnings False

DoCmd.OpenQuery "qryOne"
DoCmd.OpenQuery "qryTwo"

DoCmd.SetWarnings True

thanks :confused:
 

boblarson

Smeghead
Local time
Today, 09:43
Joined
Jan 12, 2001
Messages
32,059
Have you tried:

CurrentDb.Execute "qryOne"
CurrentDb.Execute "qryTwo"
 

halem2

Registered User.
Local time
Today, 12:43
Joined
Nov 8, 2006
Messages
180
I just tried it but it errors out since it is a select query

Cannot execute a select query. (Error 3065)
You tried to use the Execute method with a select query. The Execute method is valid only with action queries. Select queries contain a SELECT statement and can return records; action queries do not.


thanks for the help.
 

boblarson

Smeghead
Local time
Today, 09:43
Joined
Jan 12, 2001
Messages
32,059
If they are select queries, then I don't see why you are opening them but don't want to see them. There is no value in that. What exactly are you trying to accomplish with them.
 

halem2

Registered User.
Local time
Today, 12:43
Joined
Nov 8, 2006
Messages
180
I'm connecting to a tbl in a db (db1) to get information to create another tbl in a different db (db2). The information is employee demographics so what I did in order to have my own employee table in db2 was to create a make table qry to create the original employee table. I do not use the make tbl again.

After the employee tbl was created then using an unmatched qry I get the changes from db1 (such as new employees or terminations) and run an update qry against the employee tbl in db2 (mine). The whole idea is to to have a key in the employee table that I could use. If I run a make tbl qry every time, then I loose the key.

I really do not need to see the qrys, just run them.
 
Last edited:

Users who are viewing this thread

Top Bottom