Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2010
    Posts
    23

    Complex Criteria

    Hey everyone

    I am having trouble setting the criteria in one of my quaries. What I want the program to do is seperate products into two seperate queries depending on their release date.



    For the queries I have the criterias for the release date field set to >Date() and the other to <Date().

    This works great, but if the release date is unknown for a product the user leaves that input box blank. This results in the item not showing up in the not yet released querie.

    I used the code saying that if the release date = "" then the value is equal to "Unknown".

    In the first querie I now have >Date() in the criteria box and = "Unknown" in the Or box below criteria.

    When I run the program it says that this querie is either too complex or has an error in the coding.

    Is there any way around this?

    Thanks,
    Sam

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Date fields must have date or Is Null as criteria. If you only want to match when there is a date and user does not supply value, code will have to provide an alternate. Perhaps some extreme date such as #1/1/1900# so that all records will be included. Use an IIf or Nz function, like:
    >Nz(input,#1/1/1900#)
    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
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    In the first querie I now have >Date() in the criteria box and = "Unknown" in the Or box below criteria.
    Unless the field has the word "Unknown", it won't return the product. The value is Null. So try:

    >Date() in the criteria box and
    IsNull() in the Or box below criteria.

  4. #4
    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,848
    I think you need something like this in your query

    ReleaseType: iif( IsNull(ReleaseDate),"unknown",iif(ReleaseDate<=Dat e(),"Old","Future")

  5. #5
    Join Date
    Aug 2010
    Posts
    23
    If at all possible I would like to keep the Estimated Release Date field as either the correct release date or empty just to avoid confusion. I tried to put IsNull() into the Or slot but it returned an error stating that the function entered contains the wrong number of arguments. If I type "IsNull" I get the same error stated above saying that the expression is either too complex or contains an error.

    Any other ideas?

  6. #6
    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,848
    If you're using the query wizard you have to have 2 words Is Null

    IsNull() is a vba function.

  7. #7
    Join Date
    Aug 2010
    Posts
    23
    That seems like it did the trick.

    Thanks guys.

  8. #8
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by orange View Post
    If you're using the query wizard you have to have 2 words Is Null

    IsNull() is a vba function.



    Thanks, Orange. Too much VBA programming..... not enough SQL
    Sorry.

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

Similar Threads

  1. Search By Criteria - Flexible Criteria Fields
    By lilanngel in forum Access
    Replies: 0
    Last Post: 03-16-2011, 06:25 PM
  2. Replies: 3
    Last Post: 03-16-2011, 02:23 PM
  3. Help with complex Query
    By CEV in forum Queries
    Replies: 1
    Last Post: 03-12-2011, 06:54 AM
  4. Help with complex query (for me at least)
    By GrindEspresso in forum Queries
    Replies: 5
    Last Post: 01-26-2011, 11:03 AM
  5. need help, expression is too complex?
    By ice673 in forum Queries
    Replies: 5
    Last Post: 02-15-2010, 09:03 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