Results 1 to 2 of 2
  1. #1
    TechRW is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    2

    Query criteria expression builder for criteria from a form

    I have the following progression from form to report.

    1) Open form which contains Field 1 - Name of product, Field 2 - Start date, Field 3 - End date, Button - Start Macro

    2)Button activates Macro which calls for query, saves query, opens report for printing, and closes query
    Note: query date criteria expression = Between Forms![Field 2] And Forms![Field 3] (this is rough only, don't have problem with this bit)
    Criteria for Name of product is currently Forms![Field 1] (basic type expression) which works also.



    What I would like to happen.
    That if the product text box on the form is left blank that the query returns all products between the two dates.

    Problem Here
    What I have tried - IIf(Forms![Field 1]<>"",Forms![Field 1],Is Not Null) (also Is[Not]Null)
    IIf(Forms![Field 1]="","",Forms![Field 1])

    Endless frustration here.
    Please help.
    What am I doing wrong?
    What is the correct criteria expression for what I would like to happen?

    Regards
    TechRW

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    There is no need to 'call' a SELECT query, just open the report that uses the query as RecordSource.

    If you are using controls on a form to input filter criteria, those controls must be UNBOUND, otherwise will change data in record.

    WHERE datefield BETWEEN Nz(Forms!formname![Field 2], #1/1/1900#) AND Nz(Forms!formname![Field 3], #12/31/2900#) AND [Name of Product] LIKE "*" & Forms!formname![Field 1] & "*"
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-22-2014, 09:49 PM
  2. Replies: 2
    Last Post: 12-21-2013, 11:37 AM
  3. Replies: 7
    Last Post: 06-28-2013, 12:15 PM
  4. Replies: 2
    Last Post: 11-20-2012, 03:21 AM
  5. Replies: 5
    Last Post: 09-20-2012, 03:27 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