Results 1 to 4 of 4
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    Split form with Combo boxes

    I am using a split form using a query for its datasource (I have to re-arrange the fields so pardon the messiness on that)



    I have three combo boxes and they should filter with or without each other, meaning any of the filters can be selected on their own or with the others (cascading)

    I have the following code and an image of what I'm doing: The thing is that I can't get any of the boxes to filter the data. at one point the first item was filtering but now none of them are. When I step through the code it and highlight over the values, the values in the combo box that I selected are being captured but the filter isn't happening.

    Code:
    Option Compare Database
    Private m_Where As String
     
    Sub FilterThis()
    If left(m_Where, 4) = " and" Then
    m_Where = Mid(m_Where, 5)
    End If
    Me.Filter = m_Where
    'Me.FilterOn = True
     
    End Sub
    Code:
    SELECT tbl_ReqOrg.RequestingOrganization
    FROM tbl_ReqOrg INNER JOIN Query4 ON tbl_ReqOrg.[RequestingOrganization] = Query4.cboRequestByOrganization
    GROUP BY tbl_ReqOrg.RequestingOrganization;
    Code:
    SELECT tbl_RequestorID, tbl_Requestors.txtFirstName, tbl_Requestors.txtLastName, tbl_Requestors.txtResolvedName
    FROM tbl_Requestors RIGHT JOIN Query4 ON tbl_Requestors.RequestorID = Query4.RRequestorID
    GROUP BY tbl_Requestors.RequestorID, tbl_Requestors.txtFirstName, tbl_Requestors.txtLastName, tbl_Requestors.txtResolvedName
    HAVING (((tbl_Requestors.txtResolvedName)<>""));
    Code:
    Private Sub cboOrg_AfterUpdate()
    Me.FilterOn = False
    'm_Where = ""
    Me.cboOrg = ""
    'Me.cboReq = ""
    m_Where = m_Where & " and [cboRequestbyorganization] = '" & Me.cboOrg & "'"
      FilterThis
    End Sub
    Code:
    Private Sub cboSoL_AfterUpdate()
    Me.FilterOn = False
    'm_Where = ""
    'Me.cboOrg = ""
    Me.cboReq = ""
    m_Where = m_Where & " and [StationOrLine] = '" & Me.cboSoL & "'"
    End Sub
    Code:
    Private Sub cboReq_AfterUpdate()
    Me.FilterOn = False
    'm_Where = ""
    'Me.cboOrg = ""
    'Me.cboReq = ""
    m_Where = m_Where & " and [RRequestorID] = '" & Me.cboReq & "'"
    FilterThis
    End Sub
    Attached Thumbnails Attached Thumbnails Presentation1.jpg  

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    You are setting the filter, but not switching it on?
    You also appear to be clearing cboOrg and then using it? Bit hard to see the wood for the trees with all those commented out
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    Quote Originally Posted by Welshgasman View Post
    You are setting the filter, but not switching it on?
    You also appear to be clearing cboOrg and then using it? Bit hard to see the wood for the trees with all those commented out
    I see your point and updated it like so:

    Pri
    Code:
    vate Sub cboOrg_AfterUpdate()
    Me.FilterOn = False
    Me.Requery
    M_Where = ""
    Me.cboSoL = ""
    Me.cboReq = ""
     m_Where = m_Where & " and [cboRequestbyorg] = '" & Me.cboOrg & "'"
    FilterThis
    Me.FilterOn = True
    End Sub

    I did this for each one. Would I now add If/ElseIf to get all the other different combinations?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Why not set filter on in just one place, filterthis?
    Also I am not sure why you are clearing the other combos in each combo? Remember you can select these combos in any order.
    Might be better to just refer to the combos in the query?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 04-22-2021, 09:00 AM
  2. Replies: 11
    Last Post: 08-06-2014, 09:47 AM
  3. Replies: 5
    Last Post: 07-25-2014, 02:57 PM
  4. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  5. Split form filter via combo boxes
    By killermonkey in forum Forms
    Replies: 3
    Last Post: 03-21-2013, 12:37 PM

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