Printing multiple reports with one command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a command button on a form to print 5 different reports.
This is a customer database and I need to print 5 different reports for
indivisual
customers.
How can this be done?
 
Hi Marco,

This is actually very easy to do. Create a command button using the toolbox.
Display the properties dialog if it is not already displayed (View >
Properties). Select the command button. Click on the Other tab of the
properties dialog. Name this control cmdPrintReports. Then change to the
Event tab. Find the On Click event. Select Event Procedure in the drop down
arrow. Then click on the build button (the button with the three dots. You
should find your cursor blinking in-between two lines that read:

Option Compare Database
Option Explicit

Private Sub cmdPrintReports_Click()
<-----Cursor blinking here
End Sub

Add the following code so that your new procedure looks like this:

Option Compare Database
Option Explicit

Private Sub cmdPrintReports_Click()
On Error GoTo ProcError

DoCmd.OpenReport "Report1Name", acNormal
DoCmd.OpenReport "Report2Name", acNormal
DoCmd.OpenReport "Report3Name", acNormal
DoCmd.OpenReport "Report4Name", acNormal
DoCmd.OpenReport "Report5Name", acNormal

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdPrintReports_Click..."
Resume ExitProc

End Sub


Substitute the names for each of your reports, in the order that you wish to
print them, for Report1Name through Report5Name.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Back
Top