Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Posts
    4

    Post Unanswered: Multiple Search Criteria on a Single Form

    I am trying to create a form with four text boxes and one combo box. From these boxes, the user will enter the search criteria. Some of the boxes may be blank based on the criteria of the search. The goal is to return the results of the query using the search criteria.

    Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Germany
    Posts
    228
    a raw design, don't expect it to be error free, just typed it in here:

    Code:
    dim strSQL_WHERE as string
    dim blnNeedsAND as boolean
    
    'you could place your additional conditions in there
    'won't need the blnNeedsAND anymore as you'll always
    'have to place an AND
    strSQL_WHERE = ""
    blnNeedsAND  = false
    
    if not IsNull(Forms![MyForm]![MyEdit1]) then
        strSQL_WHERE = strSQL_WHERE & " MyField1 = " & _
            Forms![MyForm]![MyEdit1]
        blnNeedsAND = true
    end if
    
    if not IsNull(Forms![MyForm]![MyEdit2]) then
        if blnNeedsAND then
            strSQL_WHERE = strSQL_WHERE & " AND"
        else
            blnNeedsAND = true
        end if
        strSQL_WHERE = strSQL_WHERE & " MyField2 = " & _
            Forms![MyForm]![MyEdit2]
    end if
    
    '....
    'more fields
    '....
    
    if not IsNull(Forms![MyForm]![MyCombo]) then
        if blnNeedsAND then
            strSQL_WHERE = strSQL_WHERE & " AND"
        else
            blnNeedsAND = true
        end if
        strSQL_WHERE = strSQL_WHERE & " MyField2 = " & _
            Forms![MyForm]![MyCombo]
    end if
    
    Forms![MyOtherForm].filter = strSQL_WHERE
    Last edited by Apel; 04-10-02 at 05:45.

  3. #3
    Join Date
    Apr 2002
    Posts
    4

    Thumbs up Worked

    Thanks for the help. It worked fine

    Thanx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •