Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter a form by using VBA

Status
Not open for further replies.
Sep 2, 2002
32
DE
Hi Everybody,

I have an odd problem with Access 2002.

I am unable to filter a form by using the following code on the Load Event for the form.

Dim filter1 As date

filter1 = InputBox("Please enter a date to filter data by (e.g. 19/09/2003)?", "Spoilage")

Me.Filter = "Date1 = #" & Format(filter1, "dd/mm/yyyy") & "#"
Me.FilterOn = True

The form simply shows me nothing, even though I know that their is data for those date's held in the underlying table.
Added to this when I filter with certain date's such as "28/08/2003", it seems to work, then try it again with another date it fails. I simply got a blank form with no

I've also tried the code on the afterupdate event on a combo back and I get the same result.

Any ideas would be most appreciated

Thanks.
 
Hi

A guess, in Jet SQL you have to specify dates in american format, so maybe Format(filter1, "mm/dd/yyyy") would work ?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks that did the trick, I totally forgot about needing to put them in US Format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top