Filter syntax problem

raindrop3

Registered User.
Local time
Today, 16:04
Joined
Sep 6, 2001
Messages
98
Hello,

I have the following, simple code:

Dim From As Integer
Dim to As Integer

From = InputBox("From Date")
to = InputBox("To date")

Me.Filter = "[Year] between from and to"
Me.FilterOn = True

Access can't pass the value I entered in the inputboxes to the filter syntax. When I click on the button to activate the filter, access give me two messageboxes. (The 'querie messageboxes' for parameter input)

When I type into inpubox 'from' 1998 then I want 1998 be used in the me.filter = ....

Thanks,

Albert
 
Couple of things. Why integer not date for the variables? Second where are you using the variables? If it is in the string Me.Filter = "[Year] between from and to"
then you will need to split the string to put the variables in

Me.Filter = "[Year] Between " & From & " And " & To

As your are working with dates then it might need to be

Me.Filter = "[Year] Between #" & From & "# And #" & To & "#"

Not sure though sure that someone else can confirm etc
 
Thanks Harry!
 

Users who are viewing this thread

Back
Top Bottom