Option

  • Thread starter Thread starter rob peterson
  • Start date Start date
R

rob peterson

Where is a good example of code for a 6 option group? I looked at MS's form
sampler and didn't see anything I was looking for.

I have a form in design mode. I added the option group, which is 6 different
reports that could be previewed/printed, with an OK and cancel button on the
form.

And, am I missing something when the option wizard doesn't generate any code
for same?

thanks.
 
This is pretty simple. Whether you are using the Click event of a command
button to create the report or the After Update event of the Option Group,
the logic is the same:

Dim strDocName as String

Select Case Me.opgReportSelect
Case Is 1
strDocName = "ReportOne"
Case Is 2
strDocName = "ReportTwo"
Case Is 3
strDocName = "ReportThree"
Case Is 4
strDocName = "ReportFour"
Case Is 5
strDocName = "ReportFive"
Case Is 6
strDocName = "ReportSix"
End Select

DoCmd.OpenReport strDocName
 
Rob,

Can I ask why are you using the Option Group for the reports? With this
method your user can only print/preview one report at a time. I use
checkboxes and the have a buttons for printing and preview. Then I check to
see which checkboxes are selected and then print or preview the report
depending on what the user clicks on.

Rodger
 
Just what I needed. thanks.
rob

Klatuu said:
This is pretty simple. Whether you are using the Click event of a command
button to create the report or the After Update event of the Option Group,
the logic is the same:

Dim strDocName as String

Select Case Me.opgReportSelect
Case Is 1
strDocName = "ReportOne"
Case Is 2
strDocName = "ReportTwo"
Case Is 3
strDocName = "ReportThree"
Case Is 4
strDocName = "ReportFour"
Case Is 5
strDocName = "ReportFive"
Case Is 6
strDocName = "ReportSix"
End Select

DoCmd.OpenReport strDocName
 
If you need help let me know . . . . . . . basic idea . . . . .

'The onClick Event for the Print Report Button
Private Sub cmdPreviewReports_Click()
Call PrintReports(acPreview)
End Sub

'The onClick Event for the Print Preview Button
Private Sub cmdPrintReports_Click()
Call PrintReports(acNormal)
End Sub

'The Function to actually print/preview the reports
Function PrintReports(myView)
Dim myReportName
Dim rs, db, X, myNewSQL
Dim myMessage, myStyle, mytitle, myResponse

'************************************************
'I USED TO DO IT THIS WAY WITH OPTION BUTTONS
'PRINT TO
'If Me.frmPrintTo = 1 Then
' myView = acPreview
'Else
' myView = acNormal
'End If
'************************************************

'PRINT REPORTS
If Me.ckbListing = -1 Then
DoCmd.OpenReport "rpt_Departments", myView
End If

If Me.ckbEncompass = -1 Then
DoCmd.OpenReport "rpt_Active_Users_Departments", myView
End If

If Me.ckbActive = -1 Then
DoCmd.OpenReport "rpt_Active_Users", myView
End If

If Me.ckbInactive = -1 Then
DoCmd.OpenReport "rpt_Inactive_Users", myView
End If

If Me.ckbUpgrade = -1 Then
DoCmd.OpenReport "rpt_Upgrade", myView
End If

If Me.ckbInstallTempusOne = -1 Then
If Me.frmUpgrade = 1 Then myReportName = "rpt_PCs_Installed"
If Me.frmUpgrade = 2 Then myReportName = "rpt_PCs_NotInstalled"
If Me.frmUpgrade = 3 Then myReportName = "rpt_PCs"
DoCmd.OpenReport myReportName, myView
End If

End Function

That is just a small example of how you can use a form to print reports.

Rodger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top