Passing parameter to OpenReport

  • Thread starter Thread starter Rick Brandt
  • Start date Start date
R

Rick Brandt

James said:
The following refers to an Access 2000 db. I have a report based on a
query that prints sales totals. What I would like to do is pass a
parameter to a DoCMD.OpenReport to print a report limited to a
specific date. Here's my code:

DoCmd.OpenReport "sales by date", acViewNormal, , "TDate = 07/08/05"

TDate is the date field in my query. As I understand the
documentation the last parameter is equivalant to adding a "Where
TDate = '07/08/05'" clause in my query. When I run this code Access
ignores Where clause and returns every row in the table. Can someone
tell me where I'm going wrong? My ulitmate goal is to build an
interface that will allow a user to enter a date on a form and get
the desired data.

Thanks in advance.

Date literals need to be delimited with # so...

DoCmd.OpenReport "sales by date", acViewNormal, , "TDate = #07/08/05#"
 
The following refers to an Access 2000 db. I have a report based on a query
that prints sales totals. What I would like to do is pass a parameter to a
DoCMD.OpenReport to print a report limited to a specific date. Here's my
code:

DoCmd.OpenReport "sales by date", acViewNormal, , "TDate = 07/08/05"

TDate is the date field in my query. As I understand the documentation the
last parameter is equivalant to adding a "Where TDate = '07/08/05'" clause
in my query. When I run this code Access ignores Where clause and returns
every row in the table. Can someone tell me where I'm going wrong? My
ulitmate goal is to build an interface that will allow a user to enter a
date on a form and get the desired data.

Thanks in advance.
 
Back
Top