Combining 2 Text Feilds

T

Tim

I receive information in a text file that contains 2 address fields. Some
times the 2nd address field is blank and sometimes it contains apt numbers
or in care information. I need to combine the fields into 1 address filed
using a query. When I do this the records with data in the 2nd address
return the contents of the 2 fields but the records with nothing in the 2nd
address field return nothing. Any help is greatly appreciated

Tim
 
A

Allen Browne

Try a text box with Control Source of:
=Trim([Address1] & " " & [Address2])

If you want them on two lines:
=Trim([Address1] & Chr(13) + Chr(10) + [Address2])

This relies on a subtle difference between the normal concatenation operator
(&) and "+":
"Fred" & Null = "Fred"
"Fred" + Null = Null
 
T

Tim

That works. Thanks for the help.

Tim

Allen Browne said:
Try a text box with Control Source of:
=Trim([Address1] & " " & [Address2])

If you want them on two lines:
=Trim([Address1] & Chr(13) + Chr(10) + [Address2])

This relies on a subtle difference between the normal concatenation operator
(&) and "+":
"Fred" & Null = "Fred"
"Fred" + Null = Null
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tim said:
I receive information in a text file that contains 2 address fields. Some
times the 2nd address field is blank and sometimes it contains apt numbers
or in care information. I need to combine the fields into 1 address filed
using a query. When I do this the records with data in the 2nd address
return the contents of the 2 fields but the records with nothing in the 2nd
address field return nothing. Any help is greatly appreciated
 

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