Results 1 to 5 of 5
  1. #1
    astephan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    7

    Extract string to the left of 2 special characters

    I have a field [ITEM_ID] and I want to pull out everything to the left from the second special character.



    Example:
    S42024-L5005-A3-8
    S42024-L5100-A100-G1

    Return:
    S42024-L5005-A3
    S42024-L5100-A100

    The [ITEM_ID] field varies in the number of characters between each "-".

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    please clarify - your example is pulling everything from the left of third special character.

    or do you mean everything to the left of the last '-'

  3. #3
    astephan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    7
    everything to the left of the last '-'

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    left([Item_ID], len([Item_ID]) - instrrev([Item_ID], "-"))

  5. #5
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    or just

    left(itemid,instrrev(itemid,"-")-1)

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

Similar Threads

  1. Removing special characters
    By crowegreg in forum Queries
    Replies: 3
    Last Post: 02-26-2014, 11:56 AM
  2. column alias name with special characters?
    By btappan in forum Queries
    Replies: 3
    Last Post: 02-15-2014, 02:22 PM
  3. Search for special characters
    By davej311 in forum Queries
    Replies: 3
    Last Post: 11-20-2013, 02:35 PM
  4. Need to delete special characters
    By tlrutledge in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 03:10 AM
  5. Special Characters
    By orgelizer in forum Access
    Replies: 0
    Last Post: 03-20-2007, 08:24 PM

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