Results 1 to 7 of 7
  1. #1
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71

    Deleting text from each end of a line of text

    Hi, I have an address I would like to extract out of a field. This is what my data currently looks like:



    City\Address\state\Country
    Dallas\1234 Bob Street\TX\USA

    I would like to end up with this:

    Address
    1234 Bob Street

    I have used this; Left([Device],InStr([Device],".")-1)
    to remove everything from a dot on to the end, but not sure how to do it in the middle. The field name is "[Address]

  2. #2
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    Mid([address],InStr([ADDRESS],"\")+1,InStr(InStr([ADDRESS],"\")+1,[ADDRESS],"\")-(InStr([ADDRESS],"\")+1))

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    What dot?

    Personally, if the format is consistent I'd probably create a public function that took the field plus a position as arguments. By position I mean the 1st, 2nd, 3rd or 4th piece of info. The function would use the Split() function to break the string down to the 4 parts. The position argument would let me pull any of the pieces. For example to get what you requested (the Split function returns a zero-based array, so the second bit is 1)

    Whatever = MyFunction(Address, 1)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    This string deletes all the data in the Address column
    here is more example data:
    Address
    BOULDER/6300 DIAGONAL HIGHWAY/CO/USA
    BOULDER/6300 DIAGONAL HIGHWAY/CO/USA
    6TH OF OCTOBER CITY/RAYA DATA CENTER 26TH JULY ST. TOURISTIC ZONE//EGY
    6TH OF OCTOBER CITY/RAYA DATA CENTER 26TH JULY ST. TOURISTIC ZONE//EGY
    ABU DHABI/CORNER OF HAMDAN STREET & MUROOR STREET. MINISTRY OF ECONOMY BLDG. 1ST FLOOR - TOWER A//U
    ABU DHABI/CORNER OF HAMDAN STREET & MUROOR STREET. MINISTRY OF ECONOMY BLDG. 1ST FLOOR - TOWER A//U
    ADANA/RESAT BEY MH. ATATURK CD. NO:22 GEN ISM. NO: 22 K:6 D:18 SEYHAN//TUR
    ADANA/RESAT BEY MH. ATATURK CD. NO:22 GEN ISM. NO: 22 K:6 D:18 SEYHAN//TUR
    ALEXANDRIA/9 AL OMARAA TOWER BUILDING FIRST FLOOR ORABI SQUARE//EGY
    ALEXANDRIA/9 AL OMARAA TOWER BUILDING FIRST FLOOR ORABI SQUARE//EGY

  5. #5
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    What about an expression that will go to the last "/" and delete it and everything after it and then run it again to delete the state and then run another query to delete everything before the first "/"?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Examples in 1st post are different from 4th post. One has \ and other has /.

    Change the \ to / in the suggested expression.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    I should not have missed that. thank you very much it did the trick.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. New line in text box
    By Ruegen in forum Forms
    Replies: 1
    Last Post: 08-25-2014, 06:57 PM
  2. Unbound Text Box with line break
    By DCV0204 in forum Forms
    Replies: 3
    Last Post: 01-24-2014, 09:32 AM
  3. INSERT INTO from multi line text box
    By Only4Access in forum Forms
    Replies: 3
    Last Post: 01-08-2014, 08:06 PM
  4. Deleting all the text in a column
    By joannakf in forum Queries
    Replies: 2
    Last Post: 05-18-2012, 02:26 AM
  5. How to indent first line in text box?
    By JimmD43 in forum Forms
    Replies: 2
    Last Post: 05-08-2011, 01:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums