Results 1 to 6 of 6
  1. #1
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Extract Text Data

    I can't find how to extract the last name from a field that has last name, first name. I want to extract everything prior to the comma and the last name are varying lengths so I can't use =left([saename],5)

    The field looks like this:



    Jones, Sara
    Crouse, John
    Millichecki, Tracy

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can use the Left() function in combination with the InStr() function to find the position of the comma.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Thanks

    I tried that but since the position of the commas change because of the length of the last name it chops it up. I am trying to get a separate field for the last name and separate for first name without manually doing this for 9007 rows of data. You can take two fields and add them together and put a comma between them like Name:[lastname] & "," & [firstname] but there has to be a way to undo something like that. I have to compare this 9007 table to another table that has 9858 rows and the keys are 1) SAE last name and 2) SAE first name. I guess since I can't find anyone that knows the answer to this my only option is to manually do it. Which will take days. But no one on any forum seems to know.

  4. #4
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Give this a try:

    Code:
    LastName: Left([saename],InStr([saename],",")-1)
    Cheers,

  5. #5
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    extract

    It just returns #error

  6. #6
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    How are you "extracting" this data? By query? If so, can you post the SQL?

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

Similar Threads

  1. Replies: 3
    Last Post: 05-13-2010, 08:18 PM
  2. extract text from memo
    By lions1855 in forum Queries
    Replies: 2
    Last Post: 05-03-2010, 07:28 AM
  3. Query to extract record of particular year
    By pkg206 in forum Access
    Replies: 2
    Last Post: 11-11-2009, 10:01 PM
  4. Extract text from middle of a field
    By AccessNubie in forum Access
    Replies: 3
    Last Post: 11-02-2009, 01:13 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06:55 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