Split address field

S

Sandspur

I have an [Address] field that has one (1) or two (2) lines.

i need to split current [Address] field into two (2) fields [AddressLine1]
and [AddressLine2]


Thank you
 
J

Jeff Boyce

A bit more information needed...

If you were to tell a human assistant how to decide where to split that,
what would you tell them?

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
S

Sandspur

Line1 of [Address] field would always end in a carriage return



Jeff Boyce said:
A bit more information needed...

If you were to tell a human assistant how to decide where to split that,
what would you tell them?

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

Sandspur said:
I have an [Address] field that has one (1) or two (2) lines.

i need to split current [Address] field into two (2) fields [AddressLine1]
and [AddressLine2]


Thank you


.
 
J

John W. Vinson

I have an [Address] field that has one (1) or two (2) lines.

i need to split current [Address] field into two (2) fields [AddressLine1]
and [AddressLine2]


Thank you

AddressLine1: Left([Address] & Chr(13) & Chr(10),
InStr([Address] & Chr(13) & Chr(10), Chr(13) & Chr(10)) - 2)
AddressLine2: Mid([Address] & Chr(13) & Chr(10),
InStr([Address] & Chr(13) & Chr(10), Chr(13) & Chr(10)) + 2)

This appends a CrLf pair to the Address string (just in case there isn't one
in the string at all) and then uses the Left, Instr and Mid functions to
extract the desired portion (if there is one, AddressLine2 may well be a zero
length string if there's only one line).
 

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