Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2014

    Unanswered: Having trouble returning all values

    I have a search page that searches through 4 criteria, 2 of the criteria are combo boxes that have dropdown options to search by state and by product, I want to make it so if I don't use the drop down it returns all values, I had it working when I only had one of these criteria but when I added the second it only worked if I used both of them in my search, I did this in design view and added the criteria:

    [Forms]![industrialsearch]![productcombo] Or [Forms]![industrialsearch]![productcombo] is Null

    and I did the same for the state search, does anyone know how to fix this problem?

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Where, exactly and how, are you using

    [Forms]![industrialsearch]![productcombo] Or [Forms]![industrialsearch]![productcombo] is Null

    In VBA code, instead of

    Whatever Is Null

    you'd use


    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Apr 2014
    Provided Answers: 34
    You need a decision tree to determine the filter to apply..

    dim sWhere as string
    'the form shows all records..'this will filter them depending on user picks:
    sWhere = ""
    if not isnull(cboST) then sWhere = sWhere & "[state]='" & cboST & "' and"
    if not isnull(txtName) then sWhere = sWhere & "[Name]='" & txtName & "' and"
    if not isnull(txtProd) then sWhere = sWhere & "[Product]='" & txtProd & "' and"
    if len(sWhere)>0 then   'remove the last AND
      sWhere = left(sWhere,len(sWhere)-3)
      me.filter = sWhere
      me.filteron = true
      me.filteron = false
    end if

Posting Permissions

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