Running A Cross-Tab Query

B

Bob Barnes

I use a simple DoCmd.OpenQuery "TheQuery"....

where "TheQuery" is a Crosstab Query. It runs fine,
BUT it "displays" the result.

Is there a simple way to run the Query, but stop its
window from displaying the result?

TIA - Bob
 
W

Wayne Morgan

What do you want done with the results? What is it you want to see when the
query is "run"?
 
B

Bob Barnes

Wayne - With the results, I send that to a designated Range
in Excel via Automation - It works great. Right now. it "opens"
& covers my Form. I then Close the opened Query with a
DoCmd. Close acQuery, "The QueryName"

So, can I 'avoid" seeing the Query opening???

TIA - Bob
 
W

Wayne Morgan

Would DoCmd.TransferSpreadsheet do what you want? Use the query name in
place of a table name.

Another possibility would be to turn off the screen echo, open the query,
set focus to the form, and turn screen echo back on. This should put the
query behind the form.

Application.Echo False
DoCmd.OpenQuery "query name"
Forms!frmMyForm.SetFocus
Application.Echo True

Reset the Echo in your error handler also in case something goes wrong while
the echo is off.
 
B

Bob Barnes

Wayne - I just came back to check this.

This WORKED great...
Application.Echo False
DoCmd.OpenQuery "query name"
Forms!frmMyForm.SetFocus
Application.Echo True

THANK you - Bob
 
Top