There are two ways you can do this.
1. Set the CanShrink property of each address line control in the report to
True. In a report the canShrink property of the section in which the
controls are located would normally also be set to True unless you want the
height of the section to remain static even if the controls in it have
shrunk. Note, however, that if there are other non-shrinking controls
alongside the shrinkable control, including graphics such as lines, the
control will not shrink. You should also make sure that the text box
controls for each line of the address are contiguous top to bottom as any
white space between them won't shrink. This means making the controls higher
than the height of the text they contain so as to keep a visually pleasing
line spacing.
2. Put the whole address in a single text box control by concatenating the
lines and inserting a carriage return/line break between them. The secret
here is not to use the & (ampersand) concatenation operator to tack on the
cr/lf to each line, but to use the + (addition sign). This is because in
arithmetical expressions Nulls propagate, so Null + anything = Null.
Consequently if the line is Null the cr/lf will be suppressed.
Access provides a vbNewLine constant for the cr/lf but you can't use this
directly in the ControlSource of a control, so first create a function in a
standard module:
Function InsertLine()
InsertLine = vbNewLine
End Function
As the ControlSource for a single text box to show both address lines out:
=[AddressLine1] & (InsertLine()+[AddressLine2])
Make sure the control has a different name to either of the fields, so call
it something like txtAddressLines and set its CanGrow property to True (Yes)
in the properties sheet. Do the same for the section's CanGrow property
unless you want that to remain static. Make the control just one line high
in report design view.
Once you've created the InsertLine function you can of course use it
anywhere in the database, so it can be used on forms or in queries as well as
in the report.
Ken Sheridan
Stafford, England
JOM said:
I address on my report, some have 2 address lines while others have only 1.
e.g.
John smith
123 Address line 1
Address line 2
Las Vegas, NE 14785 - 0000
What I would like to do is if Address 2 is not available then shrink it so
that the city/state/zipcode line goes up to that line.... How do I do that?