Filtering from multiple combo boxes

Posted on 2006-05-19
Last Modified: 2010-08-05
Hi all,

an age old quetsion but ive nearly cracked it- just stuck on last part of my code.

Im using a guide i found on the web by Tony Hine about filtering with multiple comboboxes.

basically the combo's on the main form fire an activate event to requery the subform data. the subform data is a custom query in that it's field criterias references the values of the combo boxes.

therefore if i select a value from combo1 that requeries the subform data which will filter the records to the chosen value via the where clause of the query?

with me?

problem i have (apart from the form loading time now being criminally slow) is that all the events seem to run, the form requeries but it's contents doesn't change.

anyone know what is happening here?

Form name: regre
Subform Name: greg
subform source: VarStrSQL
combo box names:

SELECT qxStuds.SetId, qxStuds.Id, qxStuds.Surname, qxStuds.Forename, qxStuds.KS, qxStuds.Year, qxStuds.Class, qxStuds.House, qxStuds.Tutor, qxStuds.DOB, qxStuds.StuSex
FROM qxStuds
WHERE (((qxStuds.KS) Like fCboSearch([Forms]![regre]![greg]![cboKSFilter])) AND ((qxStuds.Year) Like fCboSearch([Forms]![regre]![greg]![cboYearFilter])) AND ((qxStuds.Class) Like fCboSearch([Forms]![regre]![greg]![cboClassFilter])) AND ((qxStuds.House) Like fCboSearch([Forms]![regre]![greg]![cboHouseFilter])) AND ((qxStuds.Tutor) Like fCboSearch([Forms]![regre]![greg]![cboTutorFilter])));

Example of event (code is the same for other 4 combos):

Private Sub cboKSFilter_AfterUpdate()
End Sub


Question by:Dubs
    LVL 77

    Expert Comment

    Hi Dubs,
    What does fCboSearch() do?


    Author Comment

    ah yes, the module may help!!

    Public Function fCboSearch(vCboSearch As Variant)

        If IsNull(vCboSearch) Or vCboSearch = "" Then
            fCboSearch = "*"
            fCboSearch = vCboSearch
        End If
        End Function



    Author Comment

    right scrap that, i was being extremely stupid:

    here's how:

    the criteria value in my recordsource query was referencing a listbox from the subform rather than the main form.  

    Of course if there is a better way oif doing this im open to suggestions. form is pretty slow now.

    LVL 1

    Accepted Solution

    Closed, 35 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Read about achieving the basic levels of HRIS security in the workplace.
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now