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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUNNING MULTIPLE QUERIES FROM ONE BUTTON

Status
Not open for further replies.

osimini1

MIS
Jun 9, 2008
29
US
Please I need your help. Will it be possible to run multiple qction queries from a single button. For example:

from open query -> make query -> query to group or sum data -> Report.

I will appreciate any suggestion or help.

Thanks
 
What have you tried? I believe there is a command button wizard that writes the code to run a query. You can then modify the code to run additional action queries from the same button. If your "query to group or sum data" is the Record Source of the report, you shouldn't need to do anything with it, just open the report.

Duane
Hook'D on Access
MS Access MVP
 
Just to expand on Duane's last comment. If the report is what you want then there's no need to run the query because the query will automatically be called when you run the report.

The Command Button wizard will generate this code to open and preview a report:
Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim stDocName As String

    stDocName = "MyReport"
    DoCmd.OpenReport stDocName, acPreview

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
End Sub
and you can see that it's the DoCmd.OpenReport that does the work. If you want to run several reports then you can add some more lines like this:
Code:
    DoCmd.OpenReport "firstReport", acPreview
    DoCmd.OpenReport "secondReport", acPreview
    DoCmd.OpenReport "thirdReport", acPreview
Note that the wizard uses the variable stDocName to hold the name of the report. I've not bothered with that and I've just used the name directly.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top