How do I hide fields that have no data when printing report

  • Thread starter Thread starter Stacie
  • Start date Start date
S

Stacie

I am trying to print a directory and have some entires that have many
fields/data and others where that specific info is not available. How can I
hide those fields that have no info available for some but print when the
info is present?
 
Hi Stacie,

I am not sure if I understood well what you need to do, but I will try:

If you need to print a report and show only those records having something
recorded in some fields then use a query in order to filter those records,
and use it a record source in your report, e.g.

SELECT YourTableName.Field1, YourTableName.Filed2, YourTableName.Field3
FROM T_Rents
WHERE (((YourTableName.Field1) Is Not Null) AND ((YourTableName.Field2) Is
Not Null)) OR (((YourTableName.Field3) Is Not Null));

The result of the above will show:

All records having something recorded in field1 and field2 (both of them not
being null) and also those (the Or condition) records having something
recorded in field3.

Any further advise will be followed if needed.

Regards,

GeorgeCY




Ο χÏήστης "Stacie" έγγÏαψε:
 
In the report, set the section's can shrink property to yes.
Set each control's can shrink property to yes.

Labels don't shrink so if you have labels in the section, you will need to add
VBA code to set the label's visible property to No when the associated control
is null.

In the format event of the section you would have code like

Me.Address2Label.Visible = Not(IsNull(Me.Address2))
Me.EmailLabel.Visible = Not(IsNull(Me.Email))

Another option to handle labels is to incorporate the label caption into the
the associated control and delete the label. The control's source would become:
="EMail: " +
If you use this approach, you will have to ensure that the control's name is
NOT Email, but something like txtEmail. In other words, the control's name
cannot be the same as any field you are using.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Thanks. I was able to hide the labels. However, although this report is
based on a query the fields that I am wanting to hide when empty are straight
address and email fields. Do I need specific instructions in the query to
achieve my desired outcome?

stacie

John Spencer said:
In the report, set the section's can shrink property to yes.
Set each control's can shrink property to yes.

Labels don't shrink so if you have labels in the section, you will need to add
VBA code to set the label's visible property to No when the associated control
is null.

In the format event of the section you would have code like

Me.Address2Label.Visible = Not(IsNull(Me.Address2))
Me.EmailLabel.Visible = Not(IsNull(Me.Email))

Another option to handle labels is to incorporate the label caption into the
the associated control and delete the label. The control's source would become:
="EMail: " +
If you use this approach, you will have to ensure that the control's name is
NOT Email, but something like txtEmail. In other words, the control's name
cannot be the same as any field you are using.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
[QUOTE]
I am trying to print a directory and have some entires that have many
fields/data and others where that specific info is not available. How can I
hide those fields that have no info available for some but print when the
info is present?[/QUOTE]
[/QUOTE]
 
Back
Top