+ Reply to Thread
Results 1 to 9 of 9

Complicated Extract from Query Field

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    6

    Complicated Extract from Query Field

    Need an efficient way to pull LAST NAME, FIRST NAME from query field. All queries return extraneous information (from canned report). I need last name, first name but queries return "TOTAL" Last Name, First Name and Middle Initial with a "." Trick is not all name fields have middle initials so a simple string function won't work (at least not one I could come up with).

    Example:
    Report returns- TOTAL ABNER, DELEON P.
    I need- ABNER, DELEON

    Another returned- TOTAL ANAYA CONCILEON, ERICA
    I Need- ANAYA CONCILEON, ERICA

    Some names have middle initials, some have multiple last names. Very complicated but I know this would be short work to some of the experts on this forum.

    thx in advance

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Complicated Extract from Query Field

    Deleted post. Didn't see it was question for MS Access.
    Last edited by AlKey; 08-22-2014 at 03:43 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Complicated Extract from Query Field

    Assume your data in Table1, your data is in field "Name1". Created an expression in Field "Name2"

    Here is the SQL statement for that query
    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-12-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Complicated Extract from Query Field

    Quote Originally Posted by alansidman View Post
    Assume your data in Table1, your data is in field "Name1". Created an expression in Field "Name2"

    Here is the SQL statement for that query
    Please Login or Register  to view this content.
    Unfortunately not proficient in SQL. HOw would I do this in a query?

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Complicated Extract from Query Field

    In your query design. Add a new column and create the expression

    Please Login or Register  to view this content.
    Change the field named Name1 to whatever your field is named.

    To see the equivalent SQL statement which should then look similar to what I provided, in the upper left corner under View, click on the dropdown and then SQL. All queries in Access require a SQL statement, MS has given you an interface to use so that you don't need to know SQL, but it will help a lot to understand it.

  6. #6
    Registered User
    Join Date
    10-12-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Complicated Extract from Query Field

    Quote Originally Posted by alansidman View Post
    In your query design. Add a new column and create the expression

    Please Login or Register  to view this content.
    Change the field named Name1 to whatever your field is named.

    To see the equivalent SQL statement which should then look similar to what I provided, in the upper left corner under View, click on the dropdown and then SQL. All queries in Access require a SQL statement, MS has given you an interface to use so that you don't need to know SQL, but it will help a lot to understand it.
    Thx but this is still giving me the middle initial and period:
    ABNER, DELEON P.
    Need ABNER, DELEON

    I do not know how to find the location of the space AFTER the comma, if could find that I think I could get this.

    THx again.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Complicated Extract from Query Field

    Create a new query using the one above as your record source. Then create a new field and use the following expression

    Please Login or Register  to view this content.
    Here is the SQL statement for comparative purposes. My previous query was Query2.

    Please Login or Register  to view this content.
    Change up your query names and field names to your field names and query names.

    My apologies. I missed that you wanted to not have the middle initial in your results.

  8. #8
    Registered User
    Join Date
    10-12-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Complicated Extract from Query Field

    Quote Originally Posted by alansidman View Post
    Create a new query using the one above as your record source. Then create a new field and use the following expression

    Please Login or Register  to view this content.
    Here is the SQL statement for comparative purposes. My previous query was Query2.

    Please Login or Register  to view this content.
    Change up your query names and field names to your field names and query names.

    My apologies. I missed that you wanted to not have the middle initial in your results.
    Awesome, worked perfectly. Now I just need to study your verbiage and figured out why it worked.

    Thx again.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Complicated Extract from Query Field

    Thanks for the feedback.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Extract a date from a field and append another field's data
    By Leroy221 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2012, 11:35 AM
  2. [SOLVED] [b]Possible to extract this complicated partial data in Excel?[b]
    By deepz12 in forum Excel General
    Replies: 8
    Last Post: 08-14-2012, 12:10 PM
  3. Complicated Query (At Least I think So)
    By Lil-Diabo in forum Excel General
    Replies: 2
    Last Post: 04-10-2008, 05:23 AM
  4. Complicated query
    By Btbxgirl in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-06-2006, 12:02 PM
  5. How to Reference a Web Query's Address Field to an external field?
    By Nivled in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-21-2005, 07:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1