A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Split address field



 
 
Thread Tools Display Modes
  #1  
Old February 14th, 2010, 04:27 PM posted to microsoft.public.access.queries
Sandspur
external usenet poster
 
Posts: 16
Default Split address field

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
  #2  
Old February 14th, 2010, 06:28 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Split address field

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" wrote in message
...
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



  #3  
Old February 14th, 2010, 07:17 PM posted to microsoft.public.access.queries
Sandspur
external usenet poster
 
Posts: 16
Default Split address field

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



"Jeff Boyce" wrote:

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" wrote in message
...
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



.

  #4  
Old February 14th, 2010, 09:30 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Split address field

On Sun, 14 Feb 2010 08:27:01 -0800, Sandspur
wrote:

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

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.