hide blank fields labels in report


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?
 
Ad

Advertisements

D

Duane Hookom

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

Al Campagna

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."
 
A

Al Campagna

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?
 
E

EricF

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:
 
Ad

Advertisements

E

Erich Strack

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:
 
Ad

Advertisements


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