Ken - I typed in the parameters area of a new query
Forms!Issues1!OpenedDate1 on the first line, then
Forms!Issues1!OpenedDate3 on the second line both datatypes date/time.
then the design view of the query builder I typed:
WHERE [OpenedDate] >=Forms!Issues1!OpenedDate1 AND [OpenedDate] <
Forms!Issues1!OpenedDate3 +1 ORDER BY [OpenedDate] DESC
It's not workingn can you please help?
Ken Sheridan said:
Tammy:
Create a query which references the text boxes on your form as parameters.
With dates it’s a good idea to declare the parameters in the query as a value
in a text box with a date in short date format can be interpreted as an
arithmetical expression and give the wrong results. So a query which
returned the matching rows in descending date order query would go something
like this:
PARAMETERS
Forms!YourForm!txtStart DATETIME,
Forms!YourForm!xtEnd DATETIME;
SELECT *
FROM Your Table
WHERE YourDateField >= Forms!YourForm!txtStart
AND YourDateField < Forms!YourForm!txtEnd + 1
ORDER BY YourDateField DESC;
The syntax used above for determining the date range is more reliable than a
BETWEEN…..AND operation as it caters for poor quality data where a 'date'
might include a non-zero time of day (which normally you would not see unless
the date/time value is formatted to do so). With a BETWEEN…..AND operation
dates on the last day of the range would not be returned if they included a
non-zero time of day. There is actually no such thing as a date value in
Access only a date/time value. A date entered without a time has a time of
day of zero, i.e. midnight at the start of the day; and a time entered
without a date is actually a time on 30 December 1899, which is day-zero in
Access's date/time implementation.
Then with a button on the form open the query:
DoCmd.OpenQuery "YourQueryName"
Or you can get a more elegantly presented result by opening a report based
on the query:
DoCmd.OpenReport "YourReportName", View:=acViewPreview
Ken Sheridan
Stafford, England