Results 1 to 2 of 2
  1. #1
    gammaman is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    56

    Using Intr function in query getting data type mismatch

    I have two tables both contaning a Last_Name Field. In one of the tables name suffixes are appened to the end of the last name and in the other table it is stored in a seperate field.



    Ex. Table 1: Last_Name = Goode Jr
    Table 2: Last_Name = Goode

    I want query to say Goode = Goode

    For the last_name in the Critera Section I have: table2.last_name = Left(Instr(table1.last_name, ' '),Instr-1)

    I get a data type mismatch.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    A few issues:

    1. You are missing all your arguments for your second INSTR function.

    2. If there are no spaces in a name, your formula would return an error (INSTR would return 0, so you would be trying to return the LEFT most -1 (negative one) spaces.

    What I would do is create a query that has a calculated field to return the LastName, up to the first space (if one exists). Then use this query in your other query, joining on this new calculated field.
    That calculated field might look something like this:
    Code:
    Adjusted_Last_Name: IIf(InStr([table1].[Last_Name],' ')>0,Left([Table1].[Last_Name],InStr([table1].[Last_Name],' ')-1),[table1].[Last_Name])

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

Similar Threads

  1. Data Type Mismatch in Query
    By dunc723 in forum Queries
    Replies: 1
    Last Post: 07-24-2013, 01:38 PM
  2. Replies: 1
    Last Post: 07-19-2013, 12:00 PM
  3. Replies: 2
    Last Post: 03-19-2013, 09:36 PM
  4. Data type mismatch in query criteria
    By TinaCa in forum Queries
    Replies: 2
    Last Post: 09-19-2011, 11:31 PM
  5. Data type mismatch in query
    By thart21 in forum Queries
    Replies: 8
    Last Post: 10-01-2010, 01:40 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