animallover
asked on
Referring to an option in an option group
I am in an Access 97 database and I have a form with 3 subforms. There is an option group in the main form and depending on which item is selected in the option group one of the subforms will become visible, otherwise they will remain invisible. I have used the following in the AfterUpdate but I keep the error "Run-time error 2427. You entered an expression that has no value."
If Me.Option1 = 1 Then
Me.subfrmChildrensPrograms .Visible = True
Else
Me.subfrmChildrensPrograms .Visible = False
End If
I planned on doing the same for Option2 and 3.
Thank you for your help.
If Me.Option1 = 1 Then
Me.subfrmChildrensPrograms
Else
Me.subfrmChildrensPrograms
End If
I planned on doing the same for Option2 and 3.
Thank you for your help.
Me.Option1.Value
Select Case Me.Option1.Value
Case 1
'do 1 stuff here
Case 2
'do 2 stuff here
Case 3
'do 3 stuff here
End Select
Case 1
'do 1 stuff here
Case 2
'do 2 stuff here
Case 3
'do 3 stuff here
End Select
ASKER
Sorry but that doesn't help me. I changed it to
If Me.Option1.Value = 1 Then
Me.subfrmChildrensPrograms .Visible = True
Else
Me.subfrmChildrensPrograms .Visible = False
End If
And I still get the same error. I have never worked with Select Case so I am not sure what to put in the "Do Stuff here" part
If Me.Option1.Value = 1 Then
Me.subfrmChildrensPrograms
Else
Me.subfrmChildrensPrograms
End If
And I still get the same error. I have never worked with Select Case so I am not sure what to put in the "Do Stuff here" part
I was about to suggest Case as well.. much easier to deal with ...
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I'm sorry, I thought I made that clear in my question.... so, yes, when the user selects a radio button in the option group I would like a specific currently-not-visible subform to become visible but when they select a different radio button a different subform would become visible and all the other ones would be changed back to not visible.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
fyed is correct, code should be in the option group control, not the member buttons.
I'm on a conference call, and you're in good hands here, so I'm going to unmonitor this question.
I'm on a conference call, and you're in good hands here, so I'm going to unmonitor this question.
ASKER
Thank you so much! I guess I didn't fully understand how option groups worked but now that I do I think I was over complicating the situation! The sample DB helped, too :)
glad I could help.
Dale
Dale
ASKER
One note for anyone else who stumbles upon this question... you must also place this code in the OnCurrent event of the form so that the correct subform is displayed when you go back through the records.