Optional Filters based on Combo Boxes

salconflu

New Member
Joined
Mar 2, 2010
Messages
13
I have a tab page with a data sheet subform that lists all the records for the linked field in the master form. I am trying to set up two simple filters on the tab page with unbound combo boxes using this approach:

Private Sub ComboFilterSpp_AfterUpdate()
If IsNull(Me.ComboFilterSpp) Then
Me.FilterOn = False
Else
Me.Survey_Report_Query_SF.Form.Filter = "[Species] = " & Me.ComboFilterSpp
Me.FilterOn = True
End If
End Sub

My Combo Boxes are ComboFilterSpp and ComboFilterYear and my Sub Form is Survey_Report_Query_SF. The field I am trying to filter is a numerical field.

I would like to keep the option of unfiltered records if the combo boxes are NULL. It seems this is a straightforward goal but I keep getting compile error messages such as "Method or data member not found".

Any help would be greatly appreciated.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Here you are setting the filter on the subform but setting your main form to allow filters. Is that what you want?

Code:
Me.Survey_Report_Query_SF.Form.Filter = "[Species] = " & Me.ComboFilterSpp
Me.FilterOn = True

Also, I'm not sure the difference but you might also try playing with Me.Survey_Report_Query_SF.Form.AllowFilter = True

I've never been clear on the difference between the two but if one works....

hth,

Rich
 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,890
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top