Address Envelope with Trim

R

Roger Bell

The following is code I use in a Report to address an envelope:
=IIf(IsNull([Postal Address]),Trim([Title for PG] & " " & [LName]) & Chr(13)
& Chr(10) & Trim([Unit/Flat] & " " & [Unit/Flat no]) & Chr(13) & Chr(10) &
Trim([Street NUmber] & "" & [Street Prefix] & " " & [Street Name]) & Chr(13)
& Chr(10) & Trim([suburb] & " " & [state] & " " & [pcode]),Trim([Title for
PG] & " " & [LName]) & Chr(13) & Chr(10) & Trim([Postal Address]) & Chr(13) &
Chr(10) & Trim([Postal Suburb] & " " & [State] & " " & [Postal PCode]))
The problem is that when there is no Unit Number, a line space is left
before the Street Number etc.
Can anyone advise me how I can correct this? Many thanks
 
D

Douglas J. Steele

You can take advantage of the fact that + treats Null values differently
than & when used for concatenation.

Null + anything is Null, while Null & anything is anything.

Rather than

Trim([Unit/Flat] & " " & [Unit/Flat no]) & Chr(13) & Chr(10) &

try

(Trim([Unit/Flat] + " " + [Unit/Flat no]) + Chr(13) + Chr(10)) &
 

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

Similar Threads

Address 1
Mailing Address 5
Mailing Address 3
Labels 4
Sorting a concatenated query problem 7
concatenated address fields 5
Address box with IIf Statement 7
Text Box in a Report 1

Top