If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Option Box Question
Hey.,...can anyone tell me why this code does not work, I am missing
something really simple ? Private Sub cmdrun01_Click() If Me.Option38 = True Then DoCmd.OpenReport "qryMainreport01", acViewPreview Else End If If Me.Option40 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If If Me.Option42 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If End Sub |
#2
|
|||
|
|||
Option Box Question
I assume the 3 option buttons you describe belong to an option group. You
don't address them directly. You address the value of the option group. Each Option in a group has an Option Value property that is an integer the option group control returns when that option is the one currently selected. The best way to do this is with a Select Case statement: Dim strRptName As String Select Case Me.MyOptionGroup Case 1 DoCmd.OpenReport "qryMainreport01", acViewPreview Case 2 DoCmd.OpenQuery "qryMainreport", acViewNormal Case 3 DoCmd.OpenQuery "qryMainreport", acViewNormal End Select -- Dave Hargis, Microsoft Access MVP "ljg08" wrote: Hey.,...can anyone tell me why this code does not work, I am missing something really simple ? Private Sub cmdrun01_Click() If Me.Option38 = True Then DoCmd.OpenReport "qryMainreport01", acViewPreview Else End If If Me.Option40 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If If Me.Option42 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If End Sub |
#3
|
|||
|
|||
Option Box Question
Cheers Dave,
Thats sorted it. Regards "Klatuu" wrote in message ... I assume the 3 option buttons you describe belong to an option group. You don't address them directly. You address the value of the option group. Each Option in a group has an Option Value property that is an integer the option group control returns when that option is the one currently selected. The best way to do this is with a Select Case statement: Dim strRptName As String Select Case Me.MyOptionGroup Case 1 DoCmd.OpenReport "qryMainreport01", acViewPreview Case 2 DoCmd.OpenQuery "qryMainreport", acViewNormal Case 3 DoCmd.OpenQuery "qryMainreport", acViewNormal End Select -- Dave Hargis, Microsoft Access MVP "ljg08" wrote: Hey.,...can anyone tell me why this code does not work, I am missing something really simple ? Private Sub cmdrun01_Click() If Me.Option38 = True Then DoCmd.OpenReport "qryMainreport01", acViewPreview Else End If If Me.Option40 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If If Me.Option42 = True Then DoCmd.OpenQuery "qryMainreport", acViewNormal Else End If End Sub |
Thread Tools | |
Display Modes | |
|
|