How conditionally display stuff on a report?

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

Allen Browne

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

Laurel

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]
 

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