Filtering from multiple combo boxes

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


Who is Participating?
Closed, 35 points refunded.
Community Support Moderator
Hi Dubs,
What does fCboSearch() do?

DubsAuthor Commented:
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


DubsAuthor Commented:
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.