Results 1 to 7 of 7
  1. #1
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19

    Multiple criteria in a query

    Hello i am doign a products to parts database.

    I have a product category combobox on a form, and I have 2 queries that I want to run that as long as the option in the 1st combobox is not "General" the other 2 comboboxes would be blank so as not needed to be filled out.

    If it is anything else in the 1st combobox then the 2 other dependant comboboxes will work.

    I have tried "General" in the criteria for the category with IS NUll in the other 2 criteria but I either get no results or I get all the results



    The first combobox selects the product category, the 2nd combobox selects the product, which then if nothing selected for 3rd combobox will sow all parts for that product. If the 3rd combobox selects the part category this will say limit the list of parts to external or internal.

    A forth combobox will split the inside of the unit up to chassis, Main pcb, PSU for example

    Thank you for any help provided have attached a screen shot of what I have
    Attached Thumbnails Attached Thumbnails Capture.PNG  

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Instead of dynamic parameterized query, consider VBA to build filter criteria and apply to form or report. 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
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19
    I am trying the code, but not having any luck. I want to filter the combo boxes on the form, the combo box this filters is cboproductname but if it equals "General" then cboproductname is not required

    Code:
    Dim strWhere As String
    Dim lngLen As Long
    If Not IsNull("Me.cboproductcat") Then
        strWhere = strWhere & "([Productcat] = " & Me.cboproductcat & ") AND "
    End If
      lngLen = Len(strWhere) - 5
        If lngLen <= 0 Then     'Nah: there was nothing in the string.
            MsgBox "No criteria", vbInformation, "Nothing to do."
        Else                    'Yep: there is something there, so remove the " AND " at the end.
            strWhere = Left$(strWhere, lngLen)
            'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
            'Debug.Print strWhere
            'Finally, apply the string as the form's Filter.
            Me.Filter = strWhere
            Me.FilterOn = True
        End If
    Thank you for any help provided

  4. #4
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19
    The ode is in the after update of cboproductcat

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    As you are still struggling, I suggest you look at the 2 example apps in this article: Multiple Group & Filter
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I am trying the code, but not having any luck
    That's as bad as "doesn't work".
    I can't tell if your post means the code runs but doesn't produce the required result, or it doesn't run at all. AFAIK, this is wrong (and should cause it to not run)
    IsNull("Me.cboproductcat")

    Remove the quotes.

    EDIT - just realized why it might run for you, but would not for me. You don't have Option Explicit at the top of your module, right up there with Option Compare. Is that correct?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, look at Allen's example again. I doubt you will see control reference within quote marks.
    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-02-2015, 12:45 PM
  2. Replies: 3
    Last Post: 10-08-2014, 10:28 AM
  3. Replies: 2
    Last Post: 04-10-2013, 03:54 PM
  4. Replies: 7
    Last Post: 01-02-2013, 11:23 PM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 AM

Tags for this Thread

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