VBA to close a query

Dannyc989

Registered User.
Local time
Today, 21:32
Joined
Dec 18, 2013
Messages
46
Hi folks,

Working on quite a large form, which has worked perfectly until recent...

I looks at around 100 different querys to return a number of different DSUM amounts, which refresh every minute or so, however today I had every one giving me an error in the unbound text box.

I was able to work out that if I opened and closed the query it fixed the issue in that box.

So I have decided to create an administrator only form restricted by the login which allows for error correction. Basically click the button and what I want it to do is:

Open the query and then
Close the query...

Currently I have (as an example rather than putting the 100 querys repetativly):

DoCmd.OpenQuery "Query1", acNormal, acEdit
DoCmd.Close "Query1"

But I get a runtime error, how can I get the query to close behind itself once opened?? I obviously have to get the to close at intervals before the others open as memory will not allow that many to open at once.

Please help
 
The correct syntax is
DoCmd.Close acQuery, "Query1"

I'd be looking at finding and fixing the source of the problem rather than looking to a work around.
 

Users who are viewing this thread

Back
Top Bottom