Milad Roohi
Milad Roohi

Reputation: 17

option button in selected mode in vba access 2010

I have a check box in a access form and i want when this check box selected , a option button in my form becomes selected.

Sorry, I know this is a amateur question but i need an answer. I used this but it doesn't work :

If (Me.Check86 = True) Then Option107.OptionValue = 1 Else Option110.OptionValue = 0 End If

Upvotes: 0

Views: 1537

Answers (1)

David Rushton
David Rushton

Reputation: 5030

Use the value property instead.

OptionValue is used when several option buttons are grouped together. It allows you to determine which of the option buttons has been selected.

Example

Private Sub Check86_Click()
' Update option buttons based on value of checkbox.

    Option107.Value = Me.Check86.Value      ' Sync check box and option.
    Option110.Value = Not Option107.Value   ' Ensures only one option button is selected at a time.
End Sub

This event is fired each time the check box is checked/unchecked. It checks/unchecks Option107 to match. It then sets Option110 to the reverse setting. I'm assuming you only want one option button checked at a time.

I've used the not operator to ensure Option110 and Check86 hold different values. When Check86 is true Option110 is not true, ie false.

Upvotes: 1

Related Questions