How to hide a text field label when the field is null? Access2003

  • Thread starter Thread starter Pearl
  • Start date Start date
P

Pearl

In MS Access 2003 report, how to hide the label attached to a text field when
the text field is blank? Example: Field Name = [MiddleName]; the label for
[MiddleName] is [MidNameLbl]. If no middle name, I do not want the label to
appear. Thanks
 
The no-code method is to change the label to a text box and set its properties:
Control Source: ="Mid. Name: " + [MiddleName]
Can Grow: No
Can Shrink: Yes
If MiddleName is null, the text box will disappear.
 
The code version would be to add some code to the Format event of whatever
section (probably the details) the control is located in. Something like:

Private Sub Details_Format

me.MidNameLbl.visible = LEN([MiddleName] & "") = 0

End Sub

The reason I used the expression on the right side of the equal sign is that
the field could also be a zero length string.

HTH
Dale
 
Duane: When I try to use your solution, the text box (label) correctly does not show when the control field has no data.

However, when there is data, the text box (label) shows #Error

What am I doing wrong?
In MS Access 2003 report, how to hide the label attached to a text field when
the text field is blank? Example: Field Name = [MiddleName]; the label for
[MiddleName] is [MidNameLbl]. If no middle name, I do not want the label to
appear. Thanks
Control Source: ="Mid. Name: " + [MiddleName]
Can Grow: No
Can Shrink: Yes
If MiddleName is null, the text box will disappear.
--
Duane Hookom
Microsoft Access MVP


"Pearl" wrote:
On Sunday, January 24, 2010 8:31 AM Dale Fye wrote:
The code version would be to add some code to the Format event of whatever
section (probably the details) the control is located in. Something like:

Private Sub Details_Format

me.MidNameLbl.visible = LEN([MiddleName] & "") = 0

End Sub

The reason I used the expression on the right side of the equal sign is that
the field could also be a zero length string.

HTH
Dale
 
Back
Top