Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate Queries in Report 1

Status
Not open for further replies.

mentasses

Technical User
Mar 23, 2004
29
GB
I have a report that runs from a command button on a form. The reportis based on a number of queries which question a linked SQL database.
At the moment I use the buttons On Click event to run the queries as:
Dim stDocName As String

stDocName = "All"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.Close
stDocName = "CountAll"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.Close
stDocName = "Total"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.Close
stDocName = "Report1"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
Exit_Command12_Click:
Exit Sub
This is not very neat and is also visible to the user which is not good.
Can you advise a better method that runs behind the scenes?
 
I'm not sure why you are opening the queries before you run the report. If you just code this portion:

stDocName = "Report1"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize

then all of the report's record source's (queries in your case) will run before the report is displayed.

-Gary
 
Thanks, I'm just being unbelievably dumb today
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top