Me.filter with datepart from 2 combo boxes?

wackywoo105

Registered User.
Local time
Yesterday, 16:09
Joined
Mar 14, 2014
Messages
203
Please help

This works:

Me.Filter = "DatePart(""m"", [due date]) =" & Me.Combo382

This also works (but obviously sets the dates to match march 2014):

Me.Filter = "DatePart(""m"", [due date]) = 3 And DatePart(""yyyy"", [due date]) = 2014"

This however does not work:

Me.Filter = "DatePart(""m"", [due date]) = & Me.Combo378 & "DatePart(""yyyy"", [due date]) = & Me.Combo380

Where am I going wrong?
 
The way to deal with stuff like this is like so:

Code:
Dim myFilterString

myFilterString="DatePart(""m"", [due date]) =" & Me.Combo382

debug.print myFilterString ' check this by pressing CTRL G - thne you see the Immediate Window (underneath the code)

Me.Filter=myFilterString
do the same for the filter bugging you ...
 
Thank you for your reply. It has helped me understand what is going on. I still can't get me.filter to accept the 2 datepart functions. Even passing the strings into me.filter doesn't work. I really don't understand where to place brackets etc so I think this may be the problem. I have tried several different versions and scoured the web but can't find a solution that works. The overall idea is fine as with just the dates entered it happily filters by month and year.
 

Users who are viewing this thread

Back
Top Bottom