Skipping lines in multiple line address query

R

Rhysickle

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
 
D

Dennis

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

Rhysickle

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
 
V

Van T. Dinh

Try:

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

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

Top