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?
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?