Date Parameter problem not showing correct info

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

I have a Parameter form that when you enter a DateFrom and DateTo, press the
Report button, the data showing up should be between the dates entered on the
parameter form.
Incorrect data is showing up and I don't know why.
Here is the criteria on the date field in the query that the Report is
getting the dates from:
=[forms]![frmErrorLogDateParam]![txtDateFrom] And <=[forms]![frmErrorLogDateParam]![txtDateTo]

The format for the dates on the parameter form are: yyyy-mm-dd

I should mention I have 4 buttons on the parameter form so entry is easy for
the user, that being Today, Week, Month, and Year. When any button is clicked,
the appropriate date shows up and the user can modify it if they choose.
I have data from April 15-April 22. When I click the Today button, the
DateFrom shows 2009-04-23 and so does the DateTo. When I run the report it
shows ZERO records, which is correct.
When I click the Week button, the DateFrom shows 2009-04-20 and DateTo shows
2009-04-24.
All records are showing up, even the ones with dates of April 15.

The dates in the table are being stored as text fields as I am using a GMT
time that gets all the dates from this function:
TimeAndDate = Format(GetCurrentGMTDate(), "yyyy-mm-dd hh:mm:ss AMPM")

So I assume I need to convert these fields first from Text to Dates?
Just not sure how exactly.
Your help is appreciated, thanks!
 
J

John Spencer MVP

Use CDate to force date string to be converted to DateTime Values. If you
have invalid strings or null values you will get an error, so to avoid that
you can also use the IsDate function.

IIF(IsDate([Your Date Time field]),CDate([Your Date Time field]),Null)

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I have a Parameter form that when you enter a DateFrom and DateTo, press the
Report button, the data showing up should be between the dates entered on the
parameter form.
Incorrect data is showing up and I don't know why.
Here is the criteria on the date field in the query that the Report is
getting the dates from:
=[forms]![frmErrorLogDateParam]![txtDateFrom] And <=[forms]![frmErrorLogDateParam]![txtDateTo]

The format for the dates on the parameter form are: yyyy-mm-dd

I should mention I have 4 buttons on the parameter form so entry is easy for
the user, that being Today, Week, Month, and Year. When any button is clicked,
the appropriate date shows up and the user can modify it if they choose.
I have data from April 15-April 22. When I click the Today button, the
DateFrom shows 2009-04-23 and so does the DateTo. When I run the report it
shows ZERO records, which is correct.
When I click the Week button, the DateFrom shows 2009-04-20 and DateTo shows
2009-04-24.
All records are showing up, even the ones with dates of April 15.

The dates in the table are being stored as text fields as I am using a GMT
time that gets all the dates from this function:
TimeAndDate = Format(GetCurrentGMTDate(), "yyyy-mm-dd hh:mm:ss AMPM")

So I assume I need to convert these fields first from Text to Dates?
Just not sure how exactly.
Your help is appreciated, thanks!
 
G

gmazza via AccessMonster.com

Thank you sir, worked awesome!
Use CDate to force date string to be converted to DateTime Values. If you
have invalid strings or null values you will get an error, so to avoid that
you can also use the IsDate function.

IIF(IsDate([Your Date Time field]),CDate([Your Date Time field]),Null)

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I have a Parameter form that when you enter a DateFrom and DateTo, press the
Report button, the data showing up should be between the dates entered on the
[quoted text clipped - 23 lines]
Just not sure how exactly.
Your help is appreciated, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top