• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

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:
[cboHouseFilter]
[cboTutorFilter]
[cboKSFilter]
[cboClassFilter]
[cboYearFilter]

VarStrSql:
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()
Me.greg.Form.Requery
End Sub

cheers

greg
0
Dubs
Asked:
Dubs
  • 2
1 Solution
 
peter57rCommented:
Hi Dubs,
What does fCboSearch() do?


Pete
0
 
DubsAuthor Commented:
ah yes, the module may help!!

Public Function fCboSearch(vCboSearch As Variant)

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

cheers

greg
0
 
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.

greg
0
 
GhostModCommented:
Closed, 35 points refunded.
GhostMod
Community Support Moderator
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now