A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Address Envelope with Trim



 
 
Thread Tools Display Modes
  #1  
Old December 14th, 2008, 08:41 AM posted to microsoft.public.access.gettingstarted
Roger Bell
external usenet poster
 
Posts: 275
Default Address Envelope with Trim

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
  #2  
Old December 14th, 2008, 11:59 AM posted to microsoft.public.access.gettingstarted
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Address Envelope with Trim

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)) &

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Roger Bell" wrote in message
news
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.