Label not appearing conditionally

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
 
A

Allen Browne

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

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

Guest

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
 
A

Allen Browne

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top