Results 1 to 5 of 5
  1. #1
    whatwouldmattdo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4

    Simple Criteria syntax mismatch - please help!

    Hi guys, just had a really quick question.. I've made the following query that takes readings from stages of a Lauter Tun (industrial beer brewing vessel).. I keep getting "Data type mismatch in criteria expression" and after some tweaking i can get the error "Invalid use of null". I swear I've tried everything and most internet assistance on the matter deals with date formatting etc - really shouldn't be so hard!

    Here's the query I'm trying to write

    Code:
    SELECT [qBH 011 - BH_PROCESS].[Start Date/Time], [qBH 011 - BH_PROCESS].[End Date/Time], [qBH 011 - BH_PROCESS].[Recipe Type], [qBH 011 - BH_PROCESS].Recipe, [qBH 011 - BH_PROCESS].[Week #], [qBH 011 - BH_PROCESS].[Brew #], [qBH 011 - BH_PROCESS].[D09 Name], [qBH 011 - BH_PROCESS].[D04 Actual], [qBH 011 - BH_PROCESS].[Step Name], Val([D09 Actual]) AS Expr1
    FROM [qBH 011 - BH_PROCESS]
    WHERE ((([qBH 011 - BH_PROCESS].[D09 Name])="LT1_DENSITY") AND ((Val([D09 Actual]))>0));
    When it's like this (missing essential criteria expression) it works:



    Code:
    SELECT [qBH 011 - BH_PROCESS].[Start Date/Time], [qBH 011 - BH_PROCESS].[End Date/Time], [qBH 011 - BH_PROCESS].[Recipe Type], [qBH 011 - BH_PROCESS].Recipe, [qBH 011 - BH_PROCESS].[Week #], [qBH 011 - BH_PROCESS].[Brew #], [qBH 011 - BH_PROCESS].[D09 Name], [qBH 011 - BH_PROCESS].[D04 Actual], [qBH 011 - BH_PROCESS].[Step Name], Val([D09 Actual]) AS Expr1
    FROM [qBH 011 - BH_PROCESS]
    WHERE ((([qBH 011 - BH_PROCESS].[D09 Name])="LT1_DENSITY"));
    but doesn't filter out the =0 values.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why do you need to use Val function? What is data in [D09 Actual]?

    Val function can't handle null so try:
    Val(Nz([D09 Actual],0))
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Further to June's remarks, why do you have spaces and slashes in your Names? This will come back to bite you again and again.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    And more - spaces, special characters, punctuation in names can all be source of aggravation. If used, must always remember to enclose names in []. Only exception is the underscore. Also, same for reserved words used as full names.
    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.

  5. #5
    whatwouldmattdo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    4
    Thanks June - it worked perfectly! I will have to pay more attention to simple variable types and their capabilities in future.

    Orange; thanks for the tip - naming conventions are something I'm starting to get the hang of.. Definitely makes life easier. I'll fix them up today actually - Cheers guys!

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

Similar Threads

  1. Data type mismatch in query criteria
    By TinaCa in forum Queries
    Replies: 2
    Last Post: 09-19-2011, 11:31 PM
  2. datatype mismatch in criteria expression
    By CyberSkillsz in forum Access
    Replies: 1
    Last Post: 06-14-2011, 10:56 AM
  3. Simple Syntax Help
    By cvegas in forum Programming
    Replies: 7
    Last Post: 04-20-2011, 01:46 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 shexe in forum Queries
    Replies: 2
    Last Post: 09-01-2010, 12:47 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