filter subform using cbo box

deb

Active Member
Joined
Feb 1, 2003
Messages
400
Access 2016

I have a form f_WorkingHours with a subform f_WorkingHoursSub.

The subform has a combobox called cboDate in the form header.

I want to filter the [Report Date] in the subform using cboDate.

Also need the option to select all dates or unfilter to show all dates if user wants to see all dates again.

I tried this....
Private Sub cboDate_AfterUpdate()

If Not IsNull(cboDate.Value) Then
f_WorkingHoursSub.Form.Filter = " [Report Date] = " cboDate
f_WorkingHoursSub.Form.FilterOn = True

Else
f_WorkingHoursSub.Form.FilterOn = False
End If
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
f_WorkingHoursSub.Form

Bold has to be the name of the subform control. Possibly they are the same, but not guaranteed that they are.
Also, if combo does not return a value of Date data type, the cboDate reference has to be delimited as a Date - maybe
"[Report Date] = #" & cboDate & "#"
Regardless, an expression has to be concatenated with a variable.

That's all based on your post, which is a bit sketchy because you didn't specify what the actual issue is - error? no result? wrong result? or on what line caused it if there was one.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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