Results 1 to 3 of 3
  1. #1
    tssrshot is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    3

    FULLNAME split

    I've found some similar threads, but none with an answer so forgive my repetition.


    My scenario so far:

    I have to import this tragically misconfigured Excel document to populate a personnel table. If anyone has a better solution on fixing this at import, that would be awesome! However, as I have it now--The names only follow these formats...

    BALDWIN, BILLY S (or)
    BALDWIN, BILLY SAM
    BALDWIN, BILLY S JR
    BALDWIN, BILLY SAM II

    Using my code I can succeed in getting LastName, FirstName, and MiddleName but ONLY if its a single character middle initial. I just need desperately to have LastName, FirstName, and Middle initial without any of the extra characters or Jr/II/III/etc.

    My Access SQL reads:

    UPDATE tbPersonnel SET
    tbPersonnel.LastName = Left(FULL_NAME,Instr(1,FULL_NAME & ",",",")-1),
    MiddleName = IIF(Right(FULL_NAME,2) Like " *",Right(FULL_NAME,1),NULL),


    FirstName = TRIM(LEFT(Mid(FULL_NAME,Instr(1,FULL_NAME,", ")+1),Instr(Mid(FULL_NAME,Instr(1,FULL_NAME," ")+1) & " "," ")));


    Also, anyone have a short answer on how to turn it proper noun easily in this process or in Access? I'm pretty new to Access, but if its a hassle, no biggie.
    Any ideas? Thanks in advance! Bryan

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    I think no matter how carefully you code this will be errors that will have to be evaluated case-by-case.

    Here is one method http://www.database-answers.com/micr...itle-case.aspx to convert to proper case.
    However, can't handle cases like O'Neil or McCain or von Trapp or van der Sloot.

    The concatenation in the InStr function should not be necessary.

    UPDATE tbPersonnel SET
    LastName = Left(FULL_NAME, InStr(FULL_NAME, ",") - 1),
    MiddleName = Mid(Mid(FULL_NAME, InStr(FULL_NAME,", ") + 2), InStr(Mid(FULL_NAME, InStr(FULL_NAME,", ") + 2), " ") + 1, 1),
    FirstName = Left(Mid(FULL_NAME, InStr(FULL_NAME,", ") + 2), InStr(Mid(FULL_NAME, InStr(FULL_NAME,", ") + 2)," ") - 1);
    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.

  3. #3
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Was wondering, why not use the Text To Columns in the Excel sheet itself.
    First use the comma as criteria and get the SurName.
    Then use space on the 2nd column generated & get Name & Middle Name & then delete the extra columns generated due to the additional space resulting in Jr/II/..
    Later import it in to access.

    Thanks

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

Similar Threads

  1. Split Database
    By gbwiii in forum Database Design
    Replies: 4
    Last Post: 05-20-2011, 09:55 AM
  2. Split Name
    By Blessy clara in forum Access
    Replies: 2
    Last Post: 05-03-2011, 03:12 PM
  3. When to split
    By Mclaren in forum Database Design
    Replies: 4
    Last Post: 07-07-2010, 07:25 AM
  4. ULS gone after split.
    By evander in forum Database Design
    Replies: 3
    Last Post: 07-06-2010, 11:49 AM
  5. Split Forms
    By bmclachlan in forum Forms
    Replies: 1
    Last Post: 08-17-2009, 02:32 AM

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