Date Time Picker and Queries

Hi,

I have developed a DB with a simple query.  The query requires the user to enter two dates then will provide the data that is between the date range entered.  (Between [Start Date] And [End Date])  When I run the query, I get a box that asks me for the starting and ending dates, just as you would expect.  What I would like to do is use the DateTimePicker ActiveX control to select the dates instead of having to type in the date.  Does anyone know how this could be accomplished?  Is this even possible?

Thanks,
Shaun
sbreenAsked:
Who is Participating?
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.

jmantha709Commented:
You will have to creat a new form.

Put your date time picker as StartDate and EndDate on that form.

Put a button on the form to run your query.

In the query the parameters would now look like :
Between Forms!MyForm![Start Date] And Forms!MyForm![End Date]
0

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
gh081410Commented:
look at this, look at GH081410 anwser
http://www.experts-exchange.com/Databases/MS_Access/Q_21793795.html

By the way, sometime with the between function, you have probleme with the date format. there is a trick to bypass it

try: between clng(format(TheDateFrom,"yyyymmdd")) and clng(format(TheDateTo,"yyyymmdd"))
0
sbreenAuthor Commented:
Could someone show me sample code for the button to run the query.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jmantha709Commented:
docmd.openquery "QueryName"
0
Richard DanekeTrainerCommented:
Hi sbreen,

jmantha709 is correct.  You need a form to use the ActiveX data picker controls and you need to refer to those dates when you run the report.  The form also needs to be open.

When you present a form for parameters, we often offer several buttons - Print Report, Print Preview, and Cancel.  The button wizards can open the report views and cancel the report, but will not hide your form while the report runs. (A certain distraction to the end user!)

Assuming the form is named frmDatePicker, insert the line Form_frmDatePicker.Visible = False before the visual basic line that opens the report.  You can quickly open the code window when you open event properties on each of your form buttons.

And, in the Report OnClose event, you can add two lines:
Form_frmDatePicker.Visible = True
DoCmd.Close Form_frmDatePicker

These will enable your frmDatePicker to show up on next use and will close the form as well.
 
0
sbreenAuthor Commented:
Thanks jmantha709 it worked great and I will give you the much deserved points.
0
jmantha709Commented:
Glad I could help !
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.