dtCriteria1=StartDateCalnedar.Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use a calendar on a form to accept a date range from a user...and
then use the range to limit the results of a query. I used the
dtCriteria1=StartDateCalendar.Value code for the Calendar...but I'm not sure
how to code my query to run based on dtCriteria1.

What do I need to do?
 
Where do you want to pull this values into? A query?

Because then you could reference the calendar control

BETWEEN Forms!MyForm!StartCalendar.Value AND Forms!MyForm!EndCalendar.Value

- Raoul
 
You can use one calendar form to do this. Name the form, PFrmDateRange.
Rename your calendar control to DateRangeCalendar. Add two text boxes to
your calendar form and name the first, StartDate and the second EndDate. Put
the following code in the AfterUpdate event of the calendar control:
If IsNull(Me!StartDate) Then
Me!StartDate = Me!DateRangeCalendar.Value
Else
Me!EndDate = Me!DateRangeCalendar.Value
End If

Then put this expression in the criteria of the date field in your query:
Between Forms!PFrmDateRange!StartDate AND Forms!PFrmDateRange!StartDate
 
You talk about a date range, I guess you have 2 calendar controls on the
form.
Not sure what the dtCriteria1=StartDateCalendar.Value is all about.

Let's say you have a calendar control for the start date: calStart
Let's say you have a calendar control for the end date: calEnd
Lets say the form is called frmDates

In your query, in design view, in the relevant column, go to the
criteria row and enter as criteria:
Between Forms!frmDates!calStart AND Forms!frmDates!calEnd

Regards,
Andreas
 
Back
Top