Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80

    Unanswered: query: empty fields

    I made a pop-up form to prompt user for letter or a word to search for. The problem is that if user doesn't enter something in each text field, query won't run. It gives an error message saying query is too complicated. How can I make the query check the fields for empty values and use * for searching if the field is empty?

    This is the code that I use to get the values from the form:

    Like CStr([Forms]![Popup]![FisrtName_popup]) & "*"
    Like CStr([Forms]![Popup]![LastName_popup]) & "*"
    Like CStr([Forms]![Popup]![School_popup]) & "*"

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: query: empty fields

    Originally posted by Sham81
    I made a pop-up form to prompt user for letter or a word to search for. The problem is that if user doesn't enter something in each text field, query won't run. It gives an error message saying query is too complicated. How can I make the query check the fields for empty values and use * for searching if the field is empty?

    This is the code that I use to get the values from the form:

    Like CStr([Forms]![Popup]![FisrtName_popup]) & "*"
    Like CStr([Forms]![Popup]![LastName_popup]) & "*"
    Like CStr([Forms]![Popup]![School_popup]) & "*"
    I think you can make a check before you make the LIKE statements
    Something like that

    Private sub cmd_search_click
    IF ISNULL('FORMS("Popup").FirstName) OR _
    ISNULL('FORMS("Popup").LastName) OR _
    ISNULL('FORMS("Popup").School) THEN
    msgbox("Please enter search criteria")
    EXIT SUB
    END IF
    End sub

  3. #3
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Thanks, I'll try it...

Posting Permissions

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