MS Access - Query rows with a specific date

I have a form which asks for a date with a button that executes another form which is supposed to show rows having the same date on it's date field.
I've created a On Open event in the form which is supposed to show the matchig rows with the following code:

Private Sub Form_Open(Cancel As Integer)
Me.Filter = DateValue([Forms]![Day]![customerfromdate]) = DateValue(fromtime)
Me.FilterOn = True
End Sub

customerfromdate - is the date I enter on the first form ("Day" is the name of the form).
fromtime - is the date field on the table which I want to show only rows who's fromtime field equals to to the date entered in customerfromdate.

However, no records are shown when the Me.FilterOn = True.

Any help would be appreciated.

Marius KaizermanITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russell FoxDatabase DeveloperCommented:
I think you just have them backwards:
Me.Filter = DateValue(fromtime) = DateValue([Forms]![Day]![customerfromdate])

Open in new window

Dale FyeOwner, Developing Solutions LLCCommented:
Generally, I do this with the OpenForm method, something like:

strCriteria = "DateValue([FromTime]) = #" & me.[customerfromdate] & "#"
docmd.openform "formname", , , strCriteria

Then you don't need code in the Open event of your 2nd form, it will automatically be filtered to the date in your original form.  Actually, if you use the WHERE argument of the OpenForm method the recordset will not be "filtered", it will have the criteria applied to the recordset, not as a form filter.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
Dale's solution should work for you. ... Hi Dale :)

As Russell pointed out, your clauses are backwards ... and you are also missing quotes around the filter STRING, and delimiters around the date.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Marius KaizermanITAuthor Commented:
Thanks for everyone's comments.
I've just tried Dale's method and removed the open event of the second form, however it now outputs and error saying: 'DateValue' is not a recognized built-in function name.
Marius KaizermanITAuthor Commented:
I took Dale's idea and used it in the open event again, like this:

Me.Filter = "DateValue([fromtime]) = #" & [Forms]![Day]![customerfromdate] & "#"
Me.FilterOn = True

Now it partially works.
The date format in [customerfromdate] and also in the second form is dd/mm/yyyy, but the results are filtered for mm/dd/yyyy,
When I enter a date in [customerfromdate] , for example 01/11/2015 it filters the records for 11/01/2015.

Any idea on how to solve this ?

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
aah, since you are using an international format and Access is produced by Americans ...

dim sFilter as string
sFilter = [Forms]![Day]![customerfromdate]
sFilter = "#" & mid(sFilter,3,3) & left(sFilter,1,3) & right(sFilter,4) & "#"
Me.Filter = "DateValue([fromtime]) = " & sFilter

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marius KaizermanITAuthor Commented:
I ended up taking all of your comments  and made something that  works for me :-)

Dim sFilter As String
sFilter = Format([Forms]![Day]![customerfromdate], "mm/dd/yyyy")
Me.Filter = "DateValue([fromtime]) = #" & sFilter & "#"
Me.FilterOn = True

Thank you all!
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, mariusk ~ happy to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.