Results 1 to 8 of 8
  1. #1
    TINMAN is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    64

    Break Name Field in Format Last Name, Middle Name First Name into Last Name Only

    I would like to break the Name Field in my Access Database in the Format Last Name, First Name Middle Name into the Last Name Only.

    I can do this in Microsoft Excel using the Left Function. Is there any comparable function I can use in a Query or Form to break out the Last Name.

    I do not know how to use Visual Basic.



    Thanks for your help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Access also has Left() as well as other string manipulation functions. Works in query, textbox, VBA.
    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
    Join Date
    Apr 2017
    Posts
    1,680
    Yes, Left() will do it in Access too. But for both Excel and Access, it will work only for cases where there are no gaps in Last Name. As an easiest example of contrary, when marring, in some countries women can keep her Last Name, and add husband's Last Name (at least I think it is possible, as I remember having seen some examples).

  4. #4
    TINMAN is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    64
    I tried using this expression from Excel in Microsoft Access and it did not work.

    =LEFT(A3,SEARCH(" ",A3)-2)

    only instead of A3 I used the Name in the Format LAST NAME, FIRST NAME MIDDLE NAME



    Access said it did not have a SEARCH function.

    What do you recommend?

    Thanks for your response.

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Code:
    ?left("LAST NAME, FIRST NAME MIDDLE NAME",instr(1,"LAST NAME, FIRST NAME MIDDLE NAME",",")-1)
    Use the left() along with Instr(). Assumes there is always a comma after last name.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    TINMAN is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    64
    Thanks for you reply.

    I ended up using this expression:

    The formula used below was used to convert a Name in the Format

    Last Name, First Name Middle Name

    To Last Name Only

    Trim(Left([Name],InStr([Name],”,”)-1))

    I am attaching a pdf file which shows the Expression Builder used.

    I have to give credit to Data Pig on You Tube as this is where I found this expression.

    Thanks for your help.

  7. #7
    TINMAN is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    64
    Thanks,

    I ended using the Left String Manipulation Function shown below:

    Trim(Left([Name],InStr([Name],”,”)-1))

  8. #8
    TINMAN is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    64
    Thanks,

    I ended up using the expression below:

    Trim(Left([Name],InStr([Name],”,”)-1))

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

Similar Threads

  1. Replies: 8
    Last Post: 02-18-2017, 05:44 AM
  2. Replies: 1
    Last Post: 02-26-2014, 03:19 PM
  3. Replies: 3
    Last Post: 05-08-2011, 12:55 PM
  4. Inserting a New Field in Middle of Table
    By AccessGeek in forum Programming
    Replies: 4
    Last Post: 03-14-2011, 09:22 AM
  5. Extract text from middle of a field
    By AccessNubie in forum Access
    Replies: 3
    Last Post: 11-02-2009, 01:13 PM

Tags for this Thread

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