Results 1 to 3 of 3
  1. #1
    nagiese is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2011
    Location
    Nashville, TN
    Posts
    43

    Question How to pull all Characters in a string after the 1st instance of a Dash


    Hello, I know this is simple, but I just can't seem to remember this function. I need an Access function(s) to pull all the characters after the 1st instance of a dash in a string, where the string set before and after the 1st instance of the dash are variable. Ex. string = A104BT-RG-XL, I need -RG-XL or string = A104BTI-RG-XXL, I need -RG-XXL. Please help my old brain remember how to do this simple task.

    Thanks so much

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Look at the Mid() function.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You would use Instr() and Mid().

    Instr() to find the dash, and Mid() to extract the characters:

    MyString = mid(mystring, instr(MyString,"-"))

    You will get an error if your string does not contain a dash, so you might want to take that into account.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-05-2015, 06:06 PM
  2. Get trailing Characters from String
    By jaykappy in forum Queries
    Replies: 4
    Last Post: 09-03-2014, 09:19 AM
  3. Omitting characters from a string
    By TonyB in forum Queries
    Replies: 4
    Last Post: 04-07-2014, 08:03 AM
  4. Replies: 5
    Last Post: 10-11-2013, 07:29 AM
  5. I need to remove a dash from a number string.
    By catguy in forum Programming
    Replies: 3
    Last Post: 02-18-2010, 02:56 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