Results 1 to 6 of 6
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    query from form with multiple criteria options

    I need to create a query that has multiple criteria selected from a form



    For example. I will always have the customer name but then the user might also choose any one or more of the following, start date, end date, number etc

    I have tried to create a select query and added the customer form element to the criteria but I am not sure how to do the rest because it will always have at least one more criteria but I am not sure which one and it may have up to 5 more criteria.
    Any help is appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    Options:

    1. parameterized query using LIKE operator with wildcard, review:
    http://datapigtechnologies.com/flash...earchform.html
    http://datapigtechnologies.com/flash...tomfilter.html
    http://datapigtechnologies.com/flash...mtoreport.html

    2. VBA code to constructed criteria string and set the form Filter and FilterOn properties, review: http://allenbrowne.com/ser-62.html
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Thank you that was very helpful, especially the first link. I did not know about setting a blank default value. I have created my form and query and everything is working EXCEPT when one of the search fields has a null or empty value in the database.

    Is there some kind of if statement that can be used so that if a value is blank or null it does not get left out of the query results?
    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    Options:

    1. create fields in query with expression that converts the nulls to a string: Nz(fieldname,"")
    then apply the wildcard criteria to those constructed fields

    2. include additional criteria for each field: Or Is Null
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Thanks for the reply,
    I tried the Nz like this Like Nz([Forms]![GUF_UpdateCurrLease_NOLeaseHistory]![RiderDate] & "*","") and applied it to only the fields that might have an empty or null value and it did not work, I still get one missing record

    i also tried Like [Forms]![GUF_UpdateCurrLease_NOLeaseHistory]![RiderDate] & "*" Or is Null and that one worked for me.

    Thanks ,I will repost if there are any other issues

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    The Nz does not go on the form control parameter, it goes on the field in the query that the parameter is under.
    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: 04-10-2013, 03:54 PM
  2. Replies: 7
    Last Post: 01-02-2013, 11:23 PM
  3. Replies: 5
    Last Post: 11-15-2012, 03:33 PM
  4. Replies: 1
    Last Post: 07-13-2011, 11:00 AM
  5. Single Form, Multiple Options
    By forrestapi in forum Forms
    Replies: 4
    Last Post: 06-30-2011, 07:09 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