Results 1 to 4 of 4
  1. #1
    taryn is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    17

    Separating data from one table column into two columns

    Hello

    I have a column, "GivenNames", which holds the first name and any additional (middle names) of individuals. The surnames are held in a different column
    "LastName".

    I need to create a query for a report which separates the data held in
    "GivenNames" into two columns: one column should just have the f
    irst name and the second column should have
    any additional (middle names) of the individual.

    Below is some sample data and how the results of the query should look:



    Sample data:
    RefCode LastName GivenNames
    SMITHJ Smith John James
    SMITHP Smith Paul Michael Charles
    SMITHK Smith Karen

    Desired result:
    RefCode LastName FirstName MiddleNames
    SMITHJ Smith John James
    SMITHP Smith Paul Michael Charles
    SMITHK Smith Karen

    I look forward to hearing from the forum.

    Kind regards.

    Taryn

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    For values like "Paul Michael James", how do you know that the Middle Name is the one that has two words and not First Name?
    I have seen people with multiple First Names like "Ann Marie" and "Bobby Jo".
    Or don't you really care about that, and if there are more than two names, you always want the First Name to be the first word, and the Middle Names to be the rest?

    If so, then use these calculated fields to get your names:
    FirstName: IIf(InStr([GivenNames]," ")>0,Left([GivenNames],InStr([GivenNames]," ")-1),[GivenNames])
    MiddleNames: IIf(InStr([GivenNames]," ")>0,Mid([GivenNames],InStr([GivenNames]," ")+1),"")

  3. #3
    taryn is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    17
    Thank you very much for your prompt reply. Query has been solved.

    Kind regards.

    Taryn

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-29-2017, 10:01 AM
  2. Replies: 2
    Last Post: 08-31-2017, 12:19 PM
  3. Replies: 5
    Last Post: 08-13-2016, 03:44 AM
  4. Replies: 1
    Last Post: 11-12-2013, 02:19 AM
  5. Separating VALUES in FIELDS/COLUMNS
    By taimysho0 in forum Queries
    Replies: 11
    Last Post: 11-30-2011, 05:32 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