searching from ranges start date and end date

yepwingtim

Registered User.
Local time
Today, 09:04
Joined
Jun 6, 2008
Messages
126
start = "#" & textbox1 & "#"
end = "#" & textbox2 & "#"

docmd.applyfilter , "me.date>=" & [start]
docmd.applyfilter , "me.date<=" & [end]

when user clicks on button, this code is applied.
Is there anyway to make this easier or more simplified?
 
Is there anyway to make this easier or more simplified?

Yes, there is:
Code:
start = "#" & [B][COLOR=red]Me.[/COLOR][/B]textbox1 & "#"
end = "#" & [B][COLOR=red]Me.[/COLOR][/B]textbox2 & "#"

Me.Filter = "[Date] Between " & start & " And " & end
Me.FilterOn = True

But also just an FYI - you should NOT have a field named DATE as that is an Access Reserved Word and by using it you can end up with some bad things happening and also have to always use square brackets around it.
 
hey bobs works great and thanks for the heads up!

is there any difference between docmd.applyfilter and me.filter?
 
is there any difference between docmd.applyfilter and me.filter?

Just that the Me.Filter is a bit more direct instead of having to go through the commands (and it can be a little more specific at times as well).
 

Users who are viewing this thread

Back
Top Bottom