Skipping lines in multiple line address query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm currently using the following expression:

Address: [Add1] & (Chr(13)+Chr(10)) & [Add2] & (Chr(13)+Chr(10)) & [Add3] &
etc...

to combine various address fields into the full address of the company
displayed on several lines in one field.

BUT, if the entry in e.g. Add2 is blank, I'd like the query to skip that
line, in the same way that mail merge in word does.

Any suggestions
 
In the field where you want to display address make the control source
=Replace(Address, (Chr(13) + Chr(10) + Chr(13) + Chr(10)), (Chr(13) +
Chr(10)))
 
Don't know if it's bad form to answer your own query, but the code below kept
on resulting in the ?NAME error message. I eventually worked out a slightly
inefficient other way of getting the desired result.

You set up several IIf expressions of the form

Line1: IIf(IsNull([Add1]),[Add1],([Add1] & Chr(13)+Chr(10)))

And then create a field which says : Line1 & Line 2 ...

But cheers for the help anyway.

Dennis said:
In the field where you want to display address make the control source
=Replace(Address, (Chr(13) + Chr(10) + Chr(13) + Chr(10)), (Chr(13) +
Chr(10)))

Rhysickle said:
I'm currently using the following expression:

Address: [Add1] & (Chr(13)+Chr(10)) & [Add2] & (Chr(13)+Chr(10)) & [Add3] &
etc...

to combine various address fields into the full address of the company
displayed on several lines in one field.

BUT, if the entry in e.g. Add2 is blank, I'd like the query to skip that
line, in the same way that mail merge in word does.

Any suggestions
 
Try:

Address: [Add1] & Chr(13) & Chr(10) & ([Add2] + Chr(13)+Chr(10)) & [Add3]
& etc...
 
Back
Top