Make Label Visible or Invisible

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

The form referred to below is on a sub-form on a main form
The code is being run on the sub-forms current event
Code is not doing anything ???
Tyring to make the Label LblPrtInv visible or invisible if a value is in
the control SentVia



If IsNull ("Forms!FTimeBillingSub!SentVia") Then
Forms!FTimeBillingSub!LblPrtInv.Enabled = False
End If
If Not IsNull ("Forms!FTimeBillingSub!SentVia") Then
Forms!FTimeBillingSub!LblPrtInv.Enabled = True
End If
 
Dave,

First of all, the ""s around the Forms!FTimeBillingSub!SentVia are not
applicable. But in any case, do you mean that FTimeBillingSub is a
subform? Therefore, it is not open as a form, but only displayed
through the subform control on the main form, so any reference to
Forms!FTimeBillingSub will not have the result you want anyway. You
would need to refer to it like this...
Forms!NameOfMainForm!FTimeBillingSub.Form!SentVia
However, I think you mean that the FTimeBillingSub subform is where the
Current event code is being called from. Right? So in that case the
Forms! reference is not necessary. Therefore, you could so it like this...

If IsNull(Me.SentVia) Then
Me.LblPrtInv.Enabled = False
Else
Me.LblPrtInv.Enabled = True
End If

However, this is neater...
Me.LblPrtInv.Enabled = Not IsNull(Me.SentVia)
 
If everything is happening within the subform then you might try this:

If IsNull (Me.SentVia) Then
Me.LblPrtInv.Visible = False
ElseIf Not IsNull (Me.SentVia) Then
Me.LblPrtInv.Visible = True
End If

You stated you wanted to make the label visible or invisible but you have enabled in your code.

What is SentVia ... text, numeric, date?

If that doesn't work you might try putting this in the SentVia AfterUpdate event. Depends on when you want it to happen.

HTH,
Debbie


| The form referred to below is on a sub-form on a main form
| The code is being run on the sub-forms current event
| Code is not doing anything ???
| Tyring to make the Label LblPrtInv visible or invisible if a value is in
| the control SentVia
|
|
|
| If IsNull ("Forms!FTimeBillingSub!SentVia") Then
| Forms!FTimeBillingSub!LblPrtInv.Enabled = False
| End If
| If Not IsNull ("Forms!FTimeBillingSub!SentVia") Then
| Forms!FTimeBillingSub!LblPrtInv.Enabled = True
| End If
 
Back
Top