Option vs textbox

  • Thread starter Thread starter hermie
  • Start date Start date
H

hermie

Hi
I have an simple option group with a yes and no radio button.
I like to have when option 1 (yes) is choosen my textbox is visble if option
2 (no) is choosen then the textbox should be invisible.
So far i created next events
Private Sub Form_Current()
If Me.SEGURO_DESEMPLEO.Value = 1 Then
Me.ESPECIFIQUE_BENEFICIOS.Visible = True
Else
Me.ESPECIFIQUE_BENEFICIOS.Visible = False
End If
End Sub

and

Private Sub BENEFICIOS_AfterUpdate()
If Me.SEGURO_DESEMPLEO.Value = 1 Then
Me.ESPECIFIQUE_BENEFICIOS.Visible = True
Else
Me.ESPECIFIQUE_BENEFICIOS.Visible = False
End If
End Sub

This results in that my textbox is now invisible

Do I something wrong?

herman
 
The code looks fine. To answer this though "This results in that my textbox
is now invisible. Do I something wrong?" we need to understand what the
value of Me!SEGURO_DESEMPLEO.Value is.

PS
You can simplify this by assigning different values to the options, ie
option 1 (yes) has a value of 1
option 2 (no) has a value of 0


Your code them becomes

Me!ESPECIFIQUE_BENEFICIOS.Visible = Me!SEGURO_DESEMPLEO.Value


Visible
 
Hi John

I figured it out and now it works, problem was that i have more option
groups in my form and I choose the wrong one. Now it is working :-)
But not understand your simplification
The optionvalue are 1 for yes and 2 for no.
When I put this code in the current and after update I get the message
Microsoft cannot find field ESPECIFIQUE_BENEFICIOS in your expression? see
below
Private Sub BENEFICIOS_AfterUpdate()
Me!ESPECIFIQUE_BENEFICIOS.Visible = Me!BENEFICIOS.Value
End Sub

and
Private Sub Form_Current()
Me!ESPECIFIQUE_BENEFICIOS.Visible = Me!BENEFICIOS.Value
End Sub

Herman
 
Glad to hear it's working. Ithink you may have missed something in my
suggestion. Unless you use the value 2 (no) as it has meaning elsewhere,
change it to be 0. In Access a non-sero is true, hence why this works.
 
Back
Top