Option group and Command buttons prob

D

David

I have an option group of 4 buttons and outside the frame there are 3 Cmd
btns ie, print, preview, close.

I cannot figure the code required when say option 2 is preselected then say
either the preview or the print button are then selected. How do I get the
Cmd btns to function with a preselected option??

Any help will be greatly appreciated
Dave
 
A

Allan Murphy

Dave

I have something similar but only two buttons in this example.

I call my option group other_duties, the buttons in this group are Other
Duties with an option value 1 and Selected Duties with an option value 2

Go to the Click event on your Preview button and add similar coding as shown
below.

You will need to change other_duties to the name of your option group and
also the report name.

Private Sub Preview_Click()

On Error GoTo Err_Preview_Click

Dim strDocName As String

Select Case other_duties

Case 1
strDocName = "rpt_other_duties"

Case 2
strDocName = "rpt_selected_other_duties"

End Select

DoCmd.OpenReport strDocName, acViewPreview

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
If Err = ConErrRptCanceled Then
Resume Exit_Preview_Click
Else
MsgBox Err.Description
Resume Exit_Preview_Click
End If

End Sub
 

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

Top