Label not appearing conditionally

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a label that will provide a warning if an expiration
date has passed.
This is the code that I am using for the form_current:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

I also have similar coding under the beforeupdate and afterupdate for the
PassExpiration field:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

What happens is - nothing. Regardless of the expiration date, the label is
not appearing.

Any suggestions?\
TIA
Papa
 
Instead of the code, how about using a text box with this in its Control
Source:

=IIf([PassExpiration] < Date(), "Expired", Null)
 
I like the idea. I removed all of the code for after update etc and changed
the label box to a text box and copied your suggestion into the control
source.
However, what I get now is a "#NAME?" error.
Why would that be?



Allen Browne said:
Instead of the code, how about using a text box with this in its Control
Source:

=IIf([PassExpiration] < Date(), "Expired", Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Papa Jonah said:
I am trying to create a label that will provide a warning if an expiration
date has passed.
This is the code that I am using for the form_current:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

I also have similar coding under the beforeupdate and afterupdate for the
PassExpiration field:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

What happens is - nothing. Regardless of the expiration date, the label
is
not appearing.

Any suggestions?\
TIA
Papa
 
Change the Name property of the text box.

Access gets confused if the text box has the same name as a field, but is
bound to something else.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Papa Jonah said:
I like the idea. I removed all of the code for after update etc and changed
the label box to a text box and copied your suggestion into the control
source.
However, what I get now is a "#NAME?" error.
Why would that be?



Allen Browne said:
Instead of the code, how about using a text box with this in its Control
Source:

=IIf([PassExpiration] < Date(), "Expired", Null)

Papa Jonah said:
I am trying to create a label that will provide a warning if an
expiration
date has passed.
This is the code that I am using for the form_current:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

I also have similar coding under the beforeupdate and afterupdate for
the
PassExpiration field:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

What happens is - nothing. Regardless of the expiration date, the
label
is
not appearing.
 
Got it thanks!

Allen Browne said:
Change the Name property of the text box.

Access gets confused if the text box has the same name as a field, but is
bound to something else.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Papa Jonah said:
I like the idea. I removed all of the code for after update etc and changed
the label box to a text box and copied your suggestion into the control
source.
However, what I get now is a "#NAME?" error.
Why would that be?



Allen Browne said:
Instead of the code, how about using a text box with this in its Control
Source:

=IIf([PassExpiration] < Date(), "Expired", Null)

I am trying to create a label that will provide a warning if an
expiration
date has passed.
This is the code that I am using for the form_current:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

I also have similar coding under the beforeupdate and afterupdate for
the
PassExpiration field:

Me.LblExpiredPassport.Visible = False
Select Case PassExpiration
Case Is = PassExpiration < Date
'Date is earlier than now

Me.LblExpiredPassport.Visible = True
Case Else

End Select

What happens is - nothing. Regardless of the expiration date, the
label
is
not appearing.
 
Back
Top