Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Button Value 1

Status
Not open for further replies.

theSizz

Technical User
Apr 22, 2002
93
US
I have a form that contains an option group with 3 option buttons (radio type).
For this example let’s call them op1,op2, and op3.
I am trying to write an if statement in the after update event of a control on the form that will put up a message box that advises the user that they need to select op1 if it’s not already selected.
This is what I wrote :
Code:
Private Sub Year_AfterUpdate()
    If Me.Option24 = False Then
        MsgBox "Please click the period button", vbOKCancel
    End If
End Sub
When the event runs I get a runtime error 2427 that says “You entered an expression that has no value”
What’s the proper syntax for notifying the user that they must select option button 1 if it’s not selected.
Thanks for your help.
 
You should test the Value of the frame control instead of the radio button.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The frame name is "PickRpt" and has the 3 radio buttons in it. How would I make reference to whether the first radio button is selected or not?
 
Test Me!PickRpt.Value

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, I'm just not getting it.

I don't understand how this would put up a message box if the user selected radio button 2 (op2) or radio button 3 (op3).

If the user does not have the first radio button selected I want to advise them that they must select this button before they continue on and try to run the report.

Hope I am making myself clear.

Thanks for looking at this.
 
The value of Me.PickRpt.Value will change depending on which option the user has selected.

Assuming the values of each option button are 1, 2 and 3:

Code:
Private Sub Year_AfterUpdate()
    If Me.PickRpt.Value <>1 Then
        MsgBox "Please click the period button", vbOKOnly
    End If
End Sub

Ed Metcalfe

Please do not feed the trolls.....
 
Thanks Ed that does the trick.

Also thank you PHV for getting the ball rolling.

theSizz

Success has many fans, failure always dies an orphan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top