Multiple Variable Criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sysdupe123
    New Member
    • Jul 2007
    • 4

    Multiple Variable Criteria

    I'm trying to create a form that has several text boxes for input by the user. I want to use the input as criteria for a query that will then display in a listbox on that same form.
    I can get it to work, but i need to have the query use the criteria entered, and if some is left out, ignore it instead of seeing it as a Null value.

    For example, I have inputs for First Name, Last Name, City, State

    User inputs Last Name and City
    The query should return all results by Last Name AND City

    I can get it to work only on an OR basis.

    Help!
    Thank you.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    In the criteria of all the fields you need to use Like "*" & Forms!frmName!c tlName & "*". You also need to Nz the fields in case any of them have Nulls.

    Comment

    • Sysdupe123
      New Member
      • Jul 2007
      • 4

      #3
      Originally posted by Rabbit
      In the criteria of all the fields you need to use Like "*" & Forms!frmName!c tlName & "*". You also need to Nz the fields in case any of them have Nulls.

      I'm not familiar with how to use Nz. Where would I put that?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        [Code=sql]
        SELECT Nz(LastName, "")
        FROM Table1
        WHERE Nz(LastName, "") Like "*" & Forms!Form1!txt LastName & "*";
        [/Code]

        Comment

        Working...