Pull down calendar

kstuart

Registered User.
Local time
Today, 13:37
Joined
Jun 17, 2002
Messages
18
I have a query that requires a date range. Right now it prompts for the from date, I enter it and click o.k., then it prompts for the to date.

I want to be able to use the date and time picker (Calendar) and have this pop up for the users to be able to enter the dates.

I was able to get the date and time picker from the toll box but can't understand how to get my query to use it.

Any help wopuld be greatly appreciated.

By the way, I'm new to access so go easy on me.
 
Create a form with two unbound fields named StartDate and EndDate. Add the calendar to the form and name it Calendar. The calendar does not have an On Click event so open the code page and put in this:

Private Sub Calendar_Click()

On Error GoTo Calendar_Click_Error

If IsNull([StartDate]) Then
[StartDate].Value = [Calendar].Value
Else
[EndDate].Value = [Calendar].Value


Calendar_Click_Exit:
Exit Sub

Calendar_Click_Error:
MsgBox Err.Description
Resume Calendar_Click_Exit

End Sub

In the Criteria line of your query put code like this:

Between [Forms]![YourFormName]![StartDate] And [Forms]![YourFormName]![EndDate]

Add a command button on the form to run your query.
 
Thanks for the help Jack.

I did what you sugested but when I try to run the query it still wants me to manually enter the dates.

Perhaps you can be a bit more specific when you metnion the unbound fields. I used a text box from the tool box to create these fields. Will that work?
 
Open your query in design mode and click on the Query menu then Parameters. See if there are any parameters there and if there are delete them. If necessary recreate the query from scratch and be sure that the criteria lines refer to your new form and the unbound fields on the form...
 
There are no parameters for the query. I created a new query and double checked everything. When I try to run the query using the command button, it opens up the query without asking for date parameters and returns no results.
 
The form with the two unbound fields with the dates must remain open for the query to get the data from the unbound fields.

I have to leave shortly so this may be my last transmission....
 
I'll take another look at all of this and let you know how it went. Thanks again for all your help up to this point.
 
Calendar

I got it working Jack. Your instructions were right on the target.

The problem was my expectation of how it would work. I thought I would be able to access the calendar from the unbound field but in trying differnet things I found that the date is entered into the field from the calendar.

Many thanks for you help.
 
Isn't persistence great? Well done and continued success...

Jack
 
Many Thanks

Just wanted to say a quick thanks for sharing this info. I have been working on a manual way of doing this and was going no where fast. 2 minutes after read your thread it was working perfectly.

Cheers

David
 

Users who are viewing this thread

Back
Top Bottom