Select An Option Button With Code

DavidWE

Registered User.
Local time
Today, 17:05
Joined
Aug 4, 2006
Messages
76
I have two option buttons - optYes and optNo. The user can select one. Is there a way to select one of the options using code depending on the value of a variable? I would want optYes to be selected if the variable PRStatus = "Y". If PRStatus = "N", optNo is selected.

If not, can I do this with a check box or another control?

It should look something like this:

Code:
If PRStatus = "Y" Then
    [optYes is true/selected]
    [optNo is false/not selected]
ElseIf PRStatus = "N" Then
    [optNo is true/selected]
    [optYes is false/not selected]
End If

Thanks
 
Are the option buttons part of a group?

If they are, then is this group bound to a field in the table?
 
Can you set the PRStatus field to a yes/no data type and use it as the control source for a check box to turn it on/off?
 
The option buttons are part of a group but are not bound to fields in a table.

Thanks for responding.
 
I should have included in my first post that the group name is grpPRStat. I am now trying to see if I can set grpPRStat to "1" or "2" depending on the value of the variable.

Ken: I'll also try your suggestion.
 
Thanks Uncle Gizmo and Ken. Both of your posts got me on the right track. For some reason I was forgetting I can manipulate the options on the group level rather than trying to change each option individually.

This works:
Code:
If PRStatus = "Y" Then
    grpPRStat.Value = "1"    'optYes has the value "1"
ElseIf PRStatus = "N" Then
    grpPRStat.Value = "2"    'optNo has the value "2"
End If
 

Users who are viewing this thread

Back
Top Bottom