Filter subform with combo boxs

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date Start date
M

mattc66 via AccessMonster.com

Hi All,

I have a main form with a datasheet subform. On the main form I have 4 Combo
boxes with 4 Check Boxes.

I want to setup the subform to be filtered based on the combo boxes that have
the check box checked.

Can anyone give me a suggestion on how I'd setup the code to handle these
variables.

Thanks
Matt
 
Matt,

Try this:

Public Function AddFilter()
With Forms!frmMainForm.fsubForm
.FilterOn = False 'Reset filter
Filter = ReturnFilter
.FilterOn = True 'Apply filter
End With
End Function

Function ReturnFilter() As String
With Me
If .cb1 = 1 Then
ReturnFilter = .cbo1.Value
End If
If .cb2 = 1 Then
ReturnFilter = ReturnFilter & .cbo2.Value
End If
If .cb3 = 1 Then
ReturnFilter = ReturnFilter & .cbo3.Value
End If
If .cb4 = 1 Then
ReturnFilter = ReturnFilter & .cbo4.Value
End If
End With
End Function

David Miller
 
So in the past I have used the LinkChild and LinkMaster of the subform to the
combo boxes. So with the example below I would clear the LinkChild and Master
flds I assume?

Thanks
Matt
 
Filter = ReturnFilter returned error.. Argument not optional (Error 449)
 
Back
Top