dban00b
asked on
How to Select an Option Button from VBA Code
In Access 2000 I used to be able to do:
MyOptionGroup.value=3, which would select the Option Button that has the OptionValue of 3 assigned to it.
But now in access 2003, I've created an Option Group, and "Value" is not a property of it.
How do I select an OptionButton from VBA Code in Access 2003 (SP3 if it matters)
Thanks!!
MyOptionGroup.value=3, which would select the Option Button that has the OptionValue of 3 assigned to it.
But now in access 2003, I've created an Option Group, and "Value" is not a property of it.
How do I select an OptionButton from VBA Code in Access 2003 (SP3 if it matters)
Thanks!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where are you running the code?
ASKER
Steps that lead to error:
1)New Form named "TestForm"
2)New OptionGroup in "TestForm" named "MyOptionGroup" with three OptionButtons,
"one"->Value 1, "two" -> Value 2, "three" ->Value 3
3)New Button named "TestButton"
4)Right Click Button, Properties, Event Tab, OnClick->Code Builder
Private Sub TestButton_Click()
me.MyOptionGroup = 3
End Sub
1)New Form named "TestForm"
2)New OptionGroup in "TestForm" named "MyOptionGroup" with three OptionButtons,
"one"->Value 1, "two" -> Value 2, "three" ->Value 3
3)New Button named "TestButton"
4)Right Click Button, Properties, Event Tab, OnClick->Code Builder
Private Sub TestButton_Click()
me.MyOptionGroup = 3
End Sub
Sounds OK and I would expect that to work.
I have just put a test together with code to cycle round values 1,2,3 and it's fine:
Private Sub Command17_Click()
If Me.Frame8 = 3 Then
Me.Frame8 = 1
Else
Me.Frame8 = Me.Frame8 + 1
End If
End Sub
I have just put a test together with code to cycle round values 1,2,3 and it's fine:
Private Sub Command17_Click()
If Me.Frame8 = 3 Then
Me.Frame8 = 1
Else
Me.Frame8 = Me.Frame8 + 1
End If
End Sub
ASKER
This sucks, there must be something different between our versions. Its weird because when I type "me." a list of controls pops up with MyOptionGroup on the list, and it auto-corrects "me" to "Me" like yours does...
Could I need some includes?
I'm using the little "Option Group" button in the toolbox that looks like an -xyz-box...wrong tool?
The Help>About first line "Microsoft(R) Office Access 2003 (11.8166.8172) SP3"
Thanks for all your help!
Could I need some includes?
I'm using the little "Option Group" button in the toolbox that looks like an -xyz-box...wrong tool?
The Help>About first line "Microsoft(R) Office Access 2003 (11.8166.8172) SP3"
Thanks for all your help!
ASKER
AHA!!! I saw your "Frame8" and decided to try it again without renaming my option group....and it worked!!!
So then I looked at the one I had named to see what was different....and sad to say, I was renaming the Label, not the optiongroup....oops.
Nonetheless, when I renamed the OptionGroup, It all worked as expected.
Thanks for your help!
So then I looked at the one I had named to see what was different....and sad to say, I was renaming the Label, not the optiongroup....oops.
Nonetheless, when I renamed the OptionGroup, It all worked as expected.
Thanks for your help!
ASKER
throws an error:
Run-time error '438':
Object doesn't support this property or method