A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Option Box Question



 
 
Thread Tools Display Modes
  #1  
Old June 18th, 2008, 05:29 PM posted to microsoft.public.access.forms
ljg08
external usenet poster
 
Posts: 11
Default 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  
Old June 18th, 2008, 05:58 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default 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  
Old June 18th, 2008, 10:14 PM posted to microsoft.public.access.forms
ljg08
external usenet poster
 
Posts: 11
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.