Filter subform with combo boxs

  • Thread starter mattc66 via AccessMonster.com
  • 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
 
D

Dave Miller

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
 
M

mattc66 via AccessMonster.com

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
 
M

mattc66 via AccessMonster.com

Filter = ReturnFilter returned error.. Argument not optional (Error 449)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top