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

Command buttons and option group

Status
Not open for further replies.

Fredgarner

Technical User
Jul 21, 2005
29
GB
I would like to deisgn a form which gives the option of printing or previewing (ie 2 choices = 2 command buttons)a choice of 3 reports (ie 3 choices). I would like to be able to highlight the report I want to print by using 3 option buttons - I know how to create a command button that either prints or previews a report, but not how to use the option buttons to link these 2 command buttons to 3 separate reports. At the moment I am having to use 6 command buttons for this operation.

Somsbody kindly posted this reply, but as I have not done this before I have no idea where the suggested code should go in the Command Button formula.

You can reference the variable of the option group and code within the command button an If Statement... ie.

If Opt_Reports = 1 Then
lcReportName = "ReportName1"
ElseIf Opt_Reports = 2 Then
lcReportName = "ReportName2"
ElseIf Opt_Reports = 3 Then
lcReportName = "ReportName3"
Else
lcReportName = "" 'Force Error
End If

Once you have variable, use that when calling either print of preview.. hthw,
 
this doesn't go in the formula, this goes into the code for the command button...

goto the events tab of the command button, and then goto onClick event, select [event procedure] option, and click on the ... button.

this will take you to the onClick event codes...

--------------------
Procrastinate Now!
 
Something like this
Code:
Private Sub cmdPrintReport_Click()
    Select Case Me.FrameOptions.Value
    Case 1
        DoCmd.OpenReport "ReportName1", acViewPreview
    Case 2
        DoCmd.OpenReport "ReportName2", acViewPreview
    Case 3
        DoCmd.OpenReport "ReportName3", acViewPreview
    Case 4
        DoCmd.OpenReport "ReportName4", acViewPreview
    End Select
End Sub

________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top