Group Option value (radio)

  • Thread starter Thread starter hoachen
  • Start date Start date
H

hoachen

Ms access 2003. I am trying to store the radio selection to db where 1 (Yes)
and 2(No) into db instead of 1 or 2. On my table, a field call "commPaid"
with data type "text". On my form, i using wizard to create group option. the
Label"lblCommPaid", the whole group "OptCommPaid", and the radio buton for
Yes "commPaidYes", No "commPaidNo".

The value 1 or 2 did store in db but i want it store as Yes or No. I use the
select case but not working!! I am pulling my hair now!!

Please someone help, your kindness will be appreciated.
 
Ms access 2003. I am trying to store the radio selection to db where 1 (Yes)
and 2(No) into db instead of 1 or 2. On my table, a field call "commPaid"
with data type "text". On my form, i using wizard to create group option. the
Label"lblCommPaid", the whole group "OptCommPaid", and the radio buton for
Yes "commPaidYes", No "commPaidNo".

The value 1 or 2 did store in db but i want it store as Yes or No. I use the
select case but not working!! I am pulling my hair now!!

Please someone help, your kindness will be appreciated.

An Option Group control - by design - returns a numeric value. The
"yes" and "no" are simply user-information labels, not the actual
value of the control.

You could use a two-row Listbox control instead, or put some simple
VBA code in the AfterUpdate event of an unbound option group. To do
the latter put a textbox named txtCommPaid (with its Visible property
set to No, if you wish) on the form bound to your commPaid field; also
have an Option Group named optCommPaid, with nothing in its Control
Source. IN the AfterUpdate event of the option group click the ...
icon, select Code Builder, and put code like

Private Sub optCommPaid_AfterUpdate()
Select Case Me!optCommPaid
Case 1
Me!txtCommPaid = "Yes"
Case 2
Me!txtCommPaid = "No"
Case Else
Me!txtCommPaid = Null
End Select
End If

Also put code in the form's Current event to do the reverse - if
txtCommPaid is "Yes" set the option group to 1, etc.
 
hoachen said:
Ms access 2003. I am trying to store the radio selection to db where 1 (Yes)
and 2(No) into db instead of 1 or 2. On my table, a field call "commPaid"
with data type "text". On my form, i using wizard to create group option. the
Label"lblCommPaid", the whole group "OptCommPaid", and the radio buton for
Yes "commPaidYes", No "commPaidNo".

The value 1 or 2 did store in db but i want it store as Yes or No.


An option group can only save integers, not text.

You could use a hidden text box bound to the field and leave
the option group unbound. Use code like this in the option
group's AfterUpdate event procedure to set the text box:

Me.thetextbox = IIf(Me.OptCommPaid = 1, "Yes", "No")
 
Back
Top