you can also try this code, add this to your main form:
Code:
Public Function fncFilterSubForm()
' MickeyMouse
' you need to rename your 10 comboboxes with
' common name + a suffix number.
'
' say, for combobox number 1, you name it
' cbx1, and for combobox 2, cbx 2, etc.
'
' now create an array here that will hold the
' Name of the field each combobox is associated
' with for filtering.
'
' on this demo i only have four fields in Table1 to filter
Dim arrFields As Variant
Dim i As Integer
Dim sFilter As String
' the array elements are associated with cbx1, cbx2, cbx3 and cbx4 respectively
' on my demo, they are as follows:
'
' change the array to reflect your fields in the form.
arrFields = Array("Country", "State", "City", "Street")
Dim m_form As Form, combo As ComboBox
' set the your form here
Set m_form = Forms!Table1
' loop though each comboboxes on the form
For i = 1 To 4
Set combo = m_form.Controls("cbx" & i)
If combo.ListIndex > -1 Then
sFilter = sFilter & " And " & arrFields(i - 1) & "='" & Replace$(combo, "'", "''") & "'"
End If
Next i
' check if there is a filter
If Len(sFilter) <> 0 Then
' remove the first 'And' from the filter
sFilter = Mid$(sFilter, 6)
With m_form
.filter = sFilter
.FilterOn = True
End With
Else
m_form.FilterOn = False
End If
Set m_form = Nothing
End Function
on design view of your Main form, add this to each of your combobox (cbx1 to cbx10)"
Code:
=fncFilterSubForm()
see table1 form on the demo.