hide blank fields labels in report

  • Thread starter Thread starter Alex Pence
  • Start date Start date
A

Alex Pence

I am creating a employee information database in Access including fields such
as names, addresses, brithdays, etc. There are some fields such as "spouse"
and "children" -names that do not apply to every employee. How can I hide a
particular label for a certain employee in the report when that field does
not apply for that employee but display the label for an employee it does
apply to?
 
I generally use a simple, no-code solution. For example, if you have a field
named [Spouse], change its Label to a Text Box and set its Control Source to:
="Spouse: " + [Spouse]
If the field is null, the new caption/text box will be null. You can set it
to Can Shrink and make sure it isn't allowed to grow and you can only see the
text part.
 
Alex,

You should be able to use the OnFormat event of the report section that
contains the fields you want to control.
If IsNull(Spouse) Then
Spouse.Visible = True
Else
Spouse.Visible = False
End if

If your Spouse Label is associated (attached) to the Spouse Text
Control, it will be invisible or visible whenever the Spouse text control is
invisible or visible.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Duane,
Very neat solution. That's a keeper...
--
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Duane Hookom said:
I generally use a simple, no-code solution. For example, if you have a
field
named [Spouse], change its Label to a Text Box and set its Control Source
to:
="Spouse: " + [Spouse]
If the field is null, the new caption/text box will be null. You can set
it
to Can Shrink and make sure it isn't allowed to grow and you can only see
the
text part.
--
Duane Hookom
Microsoft Access MVP


Alex Pence said:
I am creating a employee information database in Access including fields
such
as names, addresses, brithdays, etc. There are some fields such as
"spouse"
and "children" -names that do not apply to every employee. How can I hide
a
particular label for a certain employee in the report when that field
does
not apply for that employee but display the label for an employee it does
apply to?
 
WOW! Nice one. In all my years on Access, this is sooo cool and sooo obvious at the same time it hurts!

Many thanks for sharing!
I am creating a employee information database in Access including fields such
as names, addresses, brithdays, etc. There are some fields such as "spouse"
and "children" -names that do not apply to every employee. How can I hide a
particular label for a certain employee in the report when that field does
not apply for that employee but display the label for an employee it does
apply to?
On Wednesday, June 04, 2008 9:12 AM duanehooko wrote:
I generally use a simple, no-code solution. For example, if you have a field
named [Spouse], change its Label to a Text Box and set its Control Source to:
="Spouse: " + [Spouse]
If the field is null, the new caption/text box will be null. You can set it
to Can Shrink and make sure it isn't allowed to grow and you can only see the
text part.
--
Duane Hookom
Microsoft Access MVP


"Alex Pence" wrote:
 
Duane: This (mostly) works for me. When there is no data in the field, the text box (label) does not appear.

However, when there is data in the field, the text box (label) does not show the label, it says #Error.

What am I doing wrong?
I am creating a employee information database in Access including fields such
as names, addresses, brithdays, etc. There are some fields such as "spouse"
and "children" -names that do not apply to every employee. How can I hide a
particular label for a certain employee in the report when that field does
not apply for that employee but display the label for an employee it does
apply to?
On Wednesday, June 04, 2008 9:12 AM duanehooko wrote:
I generally use a simple, no-code solution. For example, if you have a field
named [Spouse], change its Label to a Text Box and set its Control Source to:
="Spouse: " + [Spouse]
If the field is null, the new caption/text box will be null. You can set it
to Can Shrink and make sure it isn't allowed to grow and you can only see the
text part.
--
Duane Hookom
Microsoft Access MVP


"Alex Pence" wrote:
 
Back
Top