Results 1 to 13 of 13
  1. #1
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    Data type mismatch in criteria expression


    I am trying to do the following update, with this result:
    Participate in XXX
    EOY Review
    [SDE].[CodeXXX]

    Participate in ZZZ
    EOY Review
    Yes
    IIf([SDE].[InstructionalSetting]=7,Yes,No)
    Data type mismatch in criteria expression

    The first expression is working, [SDE].[CodeXXX] is a Boolean expression (0 or 1) and I get the desired result in the Participate in XXX check box.
    Participate in ZZZ is a check box that I want to set to YES if InstructionalSetting is a 7 a text field.

    Will I have to do a separate update?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    post your SQL code please, based on the description I don't think you'll need more than one query.

  3. #3
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Here is the SQL code:
    UPDATE [EOY Review] LEFT JOIN SDE ON [EOY Review].[PEIMD ID] = SDE.PEIMSId SET [EOY Review].Dyslexia = [SDE].[Dyslexia], [EOY Review].CATE = [SDE].[CATEIndicator], [EOY Review].[Participate in At Risk] = [SDE].[AtRisk], [EOY Review].[Participate in 504] = [SDE].[Code504], [EOY Review].[Participate in Migrant] = [SDE].[Migrant], [EOY Review].[Participate in Spec Ed] = Yes
    WHERE ((([EOY Review].[Participate in Spec Ed])=IIf([SDE].[InstructionalSetting]=40 Or ([EOY Review].[Participate in Spec Ed])=41 Or ([EOY Review].[Participate in Spec Ed])=42,Yes,No)));
    I was given a wrong code for my criteria; instead of a 7 it was supposed to be 40 or 41 or 42.

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    In this part of your query: ([EOY Review].[Participate in Spec Ed])=42,Yes,No)));

    try using True, False instead of Yes, No : ([EOY Review].[Participate in Spec Ed])=42,True,False)));

    I'm not sure Access like Yes and No - A2003 doesn't.

    HTH

    John

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Boolean values in Access are -1/0 (Yes/No, True/False). Yes/No should work but I use True/False.

    What field type is [Participate in Spec Ed]?
    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.

  6. #6
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    What field type is [Participate in Spec Ed]? Check Box

    True/False didn't work either.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  8. #8
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi

    I think the error is this - you said that the field [Participate in Spec Ed] is a check box - i.e. a True/False,

    but in your IIF function you have [Participate in Spec Ed] = 42. That is the mistake - you are comparing a Boolean to an integer.

    Maybe you should be using [InstructionalSetting]=42 instead? You use [InstructionalSetting] when comparing to 40.


    John

  9. #9
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    DB for analysis (zipped)

    Here is the DB.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Good eye John_G!

    k, did you try the suggested change to the WHERE clause?
    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.

  11. #11
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Here is the current SQL with the changed WHERE clause:
    UPDATE [EOY Review] LEFT JOIN SDE ON [EOY Review].[PEIMD ID] = SDE.PEIMSId SET [EOY Review].Dyslexia = [SDE].[Dyslexia], [EOY Review].CATE = [SDE].[CATEIndicator], [EOY Review].[Participate in At Risk] = [SDE].[AtRisk], [EOY Review].[Participate in 504] = [SDE].[Code504], [EOY Review].[Participate in Migrant] = [SDE].[Migrant], [EOY Review].[Participate in Spec Ed] = True
    WHERE ((([EOY Review].[Participate in Spec Ed])=IIf([SDE].[InstructionalSetting]=40,True,False) Or ([EOY Review].[Participate in Spec Ed])=IIf([SDE].[InstructionalSetting]=41,True,False) Or ([EOY Review].[Participate in Spec Ed])=IIf([SDE].[InstructionalSetting]=42,True,False)));


    This isnt' working either.

  12. #12
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    You need quotes around you numbers because [SDE].[InstructionalSetting] is a TEXT field.

  13. #13
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    That did it. Problem solved.

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

Similar Threads

  1. Data Type Mismatch in Criteria Expression
    By dehdahdoh in forum Queries
    Replies: 13
    Last Post: 05-01-2013, 11:41 AM
  2. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  3. Data Type mismatch in criteria expression
    By elb1999 in forum Queries
    Replies: 2
    Last Post: 01-20-2012, 02:38 PM
  4. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM
  5. data type mismatch in criteria expression
    By broecher in forum Access
    Replies: 4
    Last Post: 09-10-2010, 08:29 AM

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