How conditionally display stuff on a report?

  • Thread starter Thread starter Laurel
  • Start date Start date
L

Laurel

I want to make a report that looks like the following. Labels and lines are
in square brackets. Everything else comes from the database. I've used
code to make a function to combine husbands and wives in the name and
address section. The SQL behind it has data from both the husband and wife.
If the person is not married, I don't want the [primary] and [spouse] labels
to show, nor do I want the Notes and Relatives text boxes to take up
space.... I want the line to slide up below the primary person's notes and
relatives.

Is this something I can do?

Name
Address

[Primary]
Notes Relatives

[Spouse]

Notes Relatives

[A LINE]
 
So you have a field named Spouse, and this field is null if the person is
unmarried. In your report, you want to suppress the "Spouse:" label if the
Spouse field is null.

Right-click the label, and choose Change To | Text Box.
Set the Control Source of the new text box to:
=IIf([Spouse] Is Null, Null, "Spouse:")

Set the Can Shrink property to Yes for both the Spouse text box and also the
new text box (the one that was a label.) Provided nothing else in your
report overlaps with these 2 vertically, the space will shrink up. (Make
sure Can Shrink is yes for the (Detail?) Section as well. Access should do
this automatically for you.)

Do the same for other labels you want to suppress.
 
Thanks! Works beautifully!!

Allen Browne said:
So you have a field named Spouse, and this field is null if the person is
unmarried. In your report, you want to suppress the "Spouse:" label if the
Spouse field is null.

Right-click the label, and choose Change To | Text Box.
Set the Control Source of the new text box to:
=IIf([Spouse] Is Null, Null, "Spouse:")

Set the Can Shrink property to Yes for both the Spouse text box and also
the new text box (the one that was a label.) Provided nothing else in your
report overlaps with these 2 vertically, the space will shrink up. (Make
sure Can Shrink is yes for the (Detail?) Section as well. Access should do
this automatically for you.)

Do the same for other labels you want to suppress.

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

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

Laurel said:
I want to make a report that looks like the following. Labels and lines
are in square brackets. Everything else comes from the database. I've
used code to make a function to combine husbands and wives in the name and
address section. The SQL behind it has data from both the husband and
wife. If the person is not married, I don't want the [primary] and
[spouse] labels to show, nor do I want the Notes and Relatives text boxes
to take up space.... I want the line to slide up below the primary
person's notes and relatives.

Is this something I can do?

Name
Address

[Primary]
Notes Relatives

[Spouse]

Notes Relatives

[A LINE]
 
Back
Top