Results 1 to 4 of 4
  1. #1
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    161

    Data Seperation by InStr()

    I have 1 field that is Combination of Three names Last First Middle
    eg A B C Seperated by " " ( eg A & " " & B & " " & C )

    I want A B & C separately in a form from a field.
    To Get A seperatly I used =Left([Field],Instr(1, [Field], " ") -1)
    To Get B seperatly I Used =Mid([Field], Instr(1, [Field], " ") + 1)
    But I am Getting B C
    To Get C seperatly I Used =Right([Field],1)


    C is only one Charractor.
    the Second Code is wrong. Can you please guide what went wrong? I need only B And not B C?
    Thanks in advance

  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    What if the last name or first name has a space in it?

  3. #3
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    I have some string functions at this site that may help:http://peterssoftware.com/strfn.htm

    to get "C" use =Right([Field],1)

    to get "B" use =xg_GetLastWord(left([Field],len([Field])-2))

    to get "A" use =Trim(Mid([Field], 1, InStr([Field], xg_GetLastWord(Left([Field], Len([Field]) - 2))) - 1))

    The xg_GetLastWord function is in the string functions example database above.

    This should handle last names with spaces as well.

  4. #4
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    161
    Thanks
    I got the Second String by MsgBox xg_GetSubString() fuction
    Thanks for help

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

Similar Threads

  1. InStr and Mid code creating type mismatch
    By sephiroth2906 in forum Programming
    Replies: 6
    Last Post: 09-15-2011, 10:59 AM
  2. Replies: 4
    Last Post: 01-05-2011, 07:56 AM
  3. INSTR(), quick little syntax ?
    By markjkubicki in forum Forms
    Replies: 2
    Last Post: 11-15-2010, 02:46 PM
  4. Find data, load data, and save as a new record
    By hawzmolly in forum Access
    Replies: 0
    Last Post: 10-05-2008, 03:18 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