Populating textbox with more than one row of text

W

Wullie

Hi,

I'm starting to go round in circles now and it's starting to do my head in -
I'm sure I'm missing something simple.

I have a table which contains 4 rows of an address separately (5 including
postcode) and want to display the address in one text box.

When I put the below into my text box, it shift's the row down regardless of
whether the field is blank or not

=IIf([Address1]="","",([Address1] & Chr(13) & Chr(10))) &
IIf([address2]="","",([Address2] & Chr(13) & Chr(10))) &
IIf([address3]="","",([Address3] & Chr(13) & Chr(10))) &
IIf([address4]="","",([Address4] & Chr(13) & Chr(10))) &
IIf([postcode]="","",[postcode])

At the moment I am getting

<Blank>
Address2
<Blank>
Address4
Postcode

rather than the output of

Address2
Address4
Postcode

that I would expect to get.

Anyone have any ideas what I've done wrong?

Thanks
 
A

Allen Browne

You are testing for a zero-length string, which is not the same as Null. For
more about that, see error #5 in:
Common Errors with Null
at:
http://allenbrowne.com/casu-12.html

Anyway, this may be easier:
=[Address1] + Chr(13) + Chr(10)
& [Address2] + Chr(13) + Chr(10)
& [Address3] + Chr(13) + Chr(10)
& [Address4] + Chr(13) + Chr(10)
& [postcode]

This expression relies on a subtle difference between the 2 concatenation
operators in Access:
"A" & Null => "A"
"A" + Null => Null
 

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