You may want to use an option group (radio buttons) to print or preview reports. This method will allow you to add two buttons, one for Previewing and one for Printing, giving your users an option of what they want to do.
Create an option group using the wizard. Keep track of each report, as well as the corresponding option button number Access assigns to it. You'll need it for the next step. In the properties of the option group, under the Other Tab, Name property, called it fraPrint.
Create a button for Previewing the reports. For the button's On Click event procedure, add the following code. The "Case is = #" should correspond to the the numbers Access assigned to each of your options.
Private Sub cmdPreview_Click()
On Error GoTo ErrorPreview
Select Case [fraPrint]
Case Is = 1
DoCmd.OpenReport "rpt1", acViewPreview
Case Is = 2
DoCmd.OpenReport "rpt2", acViewPreview
Case Is = 3
DoCmd.OpenReport "rpt3", acViewPreview
Case Is = 4
DoCmd.OpenReport "rpt4", acViewPreview
' If you don't chose a default value, this generates a message box if the user clicks a button without making a selection
Case Else
MsgBox "Select Report", vbExclamation, "Reports"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.