How do I hide a label based on the value of a textbox

  • Thread starter Thread starter FrunkaBlunka
  • Start date Start date
F

FrunkaBlunka

Hi


I have a textbox called txtPayment Display and a label called
lblPaymentComplete. If txtPaymentDisplay is = 0 (currency) then I
need the lblPaymentComplete to be visible if not =0 then it needs to be
hidden. Both of these are in a subform which is linked to a mainform.


1. Is my code right?
2. What event do I put the code in?


If Me!txtPaymentDisplay.Value = 0 Then
Me!lblPaymentComplete.Visible = True
End If
End Sub


PS I have a button on my main form that refreshes the form data which
is labeled caculate.
Should I put the code in the onclick event?

Thanks
Blunka
 
Hi FrunkaBlunka,

Half right... you need an else...

If Me.txtPaymentDisplay.Value = 0 Then
Me.lblPaymentComplete.Visible = True
else
me.lblPaymentComplete.Visible = False
End If

Put that into your On Current event for the form, and if you have fields
that update the value, then you might want to also include that code in the
after Update event of those fields.

Hope this helps.

Damian.
 
Thanks Damian works perfectly now.

Blunka


Damian said:
Hi FrunkaBlunka,

Half right... you need an else...

If Me.txtPaymentDisplay.Value = 0 Then
Me.lblPaymentComplete.Visible = True
else
me.lblPaymentComplete.Visible = False
End If

Put that into your On Current event for the form, and if you have fields
that update the value, then you might want to also include that code in the
after Update event of those fields.

Hope this helps.

Damian.
 
Back
Top