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

Print Reports Using Option Group

How to

Print Reports Using Option Group

by  Garridon  Posted    (Edited  )
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"


End Select

ExitPreview:
Exit Sub

ErrorPreview:
MsgBox err.Description
Resume ExitPreview

End Sub

To Print reports as well, just add a print button. Paste the same code in, but change the acViewPreview to acViewNormal.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top