Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate but don't display field if blank

Status
Not open for further replies.

Aerowolf

Programmer
Nov 6, 2002
64
I want to print a shipping label. I have 3 address fields.
I need to be able to print all 3 but would rather not print address2 or 3 if they are blank.

Here's my expression so far:

=[COMPANY] & Chr(13) & Chr(10) & [ADDRESS1] & Chr(13) & Chr(10) & [ADDRESS2] & Chr(13) & Chr(10) & [ADDRESS3] & Chr(13) & Chr(10) & [CITY] & ", " & [STATE/PROV] & " " & [ZIP]

Right now if ADDRESS2 or 3 are blank I get blank lines where they would be. Is there a way to not show these fields if they are blank?

Thanks

Edwin
 
Try Conditional If

... [ADDRESS1] & IIF([ADDRESS2]="","",Chr(13) & Chr(10) & [ADDRESS2]) & ...




 
Just as a note, use vbCrLf instead of Chr(13) & Chr(10)

eg.

=[COMPANY] & vbCrLf & [ADDRESS1]

it's much faster to execute.

There are two ways to write error-free programs; only the third one works.
 
This worked great!!

The vbCrLf did not work however. I'm using Access2000 and I put this expression right in the Control Source property of the text box.

Edwin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top