Results 1 to 2 of 2
  1. #1
    sombiatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3

    Parse First Name

    Hi All,

    I am trying to parse out a full name field into a First Name, Last Name, and Middle Initial field. The data is currently formatted as follows:

    Name
    MOORE,RICHARD
    TAYLOR,MARTIN A
    BROWN,SUSAN A
    ROCKWELL,BRITTNEY E
    LORD-PAGE,TREVOR

    I am able to successfully parse out the last name and the middle initial with the following.



    MiddleInitial: Mid([BarProceduresInsuranceQueryC.Name],InStr([BarProceduresInsuranceQueryC.Name] & " "," ")+1,1)
    LastName: Left([BarProceduresInsuranceQueryC.Name],InStr(1,[BarProceduresInsuranceQueryC.Name],",")-1)

    I am having trouble with the first name because I don't know how to stop grabbing the middle initial. I currently have this:

    FirstName: Mid([dbo_BarVisits.Name],InStr(1,[dbo_BarVisits.Name],",")+1)

    But, with the name examples above, it is giving me the following:

    RICHARD
    MARTIN A
    SUSAN A
    BRITTNEY E
    TREVOR

    How do I change it so that it stops pulling the middle initial?

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    if the left char of the right 2 chars is a space then
    it is an initial so skip the last char
    else
    use the whole word

    iif(left(right([dbo_BarVisits.Name],2),1) = " " ,Mid([dbo_BarVisits.Name],InStr(1,[dbo_BarVisits.Name],",")+1, len(Mid([dbo_BarVisits.Name],InStr(1,[dbo_BarVisits.Name],",")+1)-1), Mid([dbo_BarVisits.Name],InStr(1,[dbo_BarVisits.Name],",")+1))

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

Similar Threads

  1. Parse text file
    By Ruegen in forum Programming
    Replies: 5
    Last Post: 08-19-2014, 09:13 PM
  2. Query: Parse Digits
    By JangLang in forum Access
    Replies: 2
    Last Post: 09-13-2013, 06:52 PM
  3. Parse in Query
    By JangLang in forum Access
    Replies: 7
    Last Post: 05-26-2013, 12:51 PM
  4. Parse Data by Month
    By dccjr in forum Queries
    Replies: 6
    Last Post: 04-01-2013, 09:15 AM
  5. parse on the fly when running a query
    By johnmerlino in forum Queries
    Replies: 9
    Last Post: 11-19-2010, 10: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