Label Visible Code

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

tbDate being a text box for a date and lblDate is a lable
If tbDate (has a any date) lblDate.Visible = True
Else
lblDate.Visible = False
 
tbDate being a text box for a date and lblDate is a lable
If tbDate (has a any date) lblDate.Visible = True
Else
lblDate.Visible = False

If we assume by your "If tbDate (has a any date)" that you mean if the
control is Null, not that it is a valid date.

Me.[lblDate].Visible = Not IsNull([tbDate])

If you did mean a valid date, then
Me.[lblDate].Visible = IsDate([tbDate])

However entries, for example, like 7/13 or 7/32 will be recognized as
a valid date, as Access will assume 7/13/2009 in the first instance,
and 7/1/1932 in the second.
 
There is a simple way to do this without code:

1. Right-click the label, and Change To | Text Box.

2. Set the Control Source of the new text box to:
=IIf([tbDate] Is Null, Null, "whatever the label says:")
 
Thanks Fred "BRILLIANT" Regards Bob

fredg said:
tbDate being a text box for a date and lblDate is a lable
If tbDate (has a any date) lblDate.Visible = True
Else
lblDate.Visible = False

If we assume by your "If tbDate (has a any date)" that you mean if the
control is Null, not that it is a valid date.

Me.[lblDate].Visible = Not IsNull([tbDate])

If you did mean a valid date, then
Me.[lblDate].Visible = IsDate([tbDate])

However entries, for example, like 7/13 or 7/32 will be recognized as
a valid date, as Access will assume 7/13/2009 in the first instance,
and 7/1/1932 in the second.
 
Thanks Allen but I am getting a comer error when I enter this into Control
Source
Regards Bob

Allen Browne said:
There is a simple way to do this without code:

1. Right-click the label, and Change To | Text Box.

2. Set the Control Source of the new text box to:
=IIf([tbDate] Is Null, Null, "whatever the label says:")

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

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

Bob Vance said:
tbDate being a text box for a date and lblDate is a lable
If tbDate (has a any date) lblDate.Visible = True
Else
lblDate.Visible = False
 
Back
Top