Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Date Time Picker and Queries

Posted on 2006-03-30
Medium Priority
Last Modified: 2010-08-11

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?

Question by:sbreen
LVL 15

Accepted Solution

jmantha709 earned 2000 total points
ID: 16332540
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]

Expert Comment

ID: 16332844
look at this, look at GH081410 anwser

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"))

Author Comment

ID: 16333139
Could someone show me sample code for the button to run the query.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 15

Expert Comment

ID: 16333171
docmd.openquery "QueryName"
LVL 19

Expert Comment

by:Richard Daneke
ID: 16333309
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.

Author Comment

ID: 16333395
Thanks jmantha709 it worked great and I will give you the much deserved points.
LVL 15

Expert Comment

ID: 16333417
Glad I could help !

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question