DoCmd.OpenReport w/ a Parameter

M

Mike P

I have a report that has the parameter [Enter_Date]. The report also calls a
query which has a parameter [Enter_Date]. When I run the report, a
parameter windows pops us, I enter the date, and the report runs fine.
However, I am now trying to run this report from a program, without prompting
the user. I am not have any luck and am wondering if I am entering the
syntax wrong as the window still pops up asking for the Enter_Date
paramenter. The syntax I am using is:

DoCmd.OpenReport "rptBuyReport", acViewPreview, , "[Enter_Date] = #3/3/2008#"

Any ideas here? I wish to run about 20 reports based on the same date and
this would let me automate the process and not require the user to
[Enter_Date] 20 times. I am using Access 2007 on XP.

Thanks,
Mike P
 
N

Nicholas Scarpinato

One question, before I can really help much... are you using today's date, or
a specific date entered by the user? Because if you're using today's date you
could just open a hidden form when the database opens, a form with a textbox
with the DefaultValue set to 'Format(Now(),"Short Date")', and then use the
date stored in that form to run your reports.
 
M

Mike P

I am using a date entered by the user. My hope is to have the user enter
the date once, the run 20 different reports based off of that date. I hope
to use the DoCmd.OpenReport 20 times having the user enter the date once.

I plan to get the date from a form. So a more exact syntax would be
something like
DoCmd.OpenReport "rptBuyReport", acViewPreview, , "[Enter_Date] = #" & _
Me!datEnterDate & "#"

It still not working. My report uses a parameter, Enter_Date. The report
record source query qry1 built off of query qry2 which also uses the
parameter Enter_Date.

Thanks for help with this!

Nicholas Scarpinato said:
One question, before I can really help much... are you using today's date, or
a specific date entered by the user? Because if you're using today's date you
could just open a hidden form when the database opens, a form with a textbox
with the DefaultValue set to 'Format(Now(),"Short Date")', and then use the
date stored in that form to run your reports.

Mike P said:
I have a report that has the parameter [Enter_Date]. The report also calls a
query which has a parameter [Enter_Date]. When I run the report, a
parameter windows pops us, I enter the date, and the report runs fine.
However, I am now trying to run this report from a program, without prompting
the user. I am not have any luck and am wondering if I am entering the
syntax wrong as the window still pops up asking for the Enter_Date
paramenter. The syntax I am using is:

DoCmd.OpenReport "rptBuyReport", acViewPreview, , "[Enter_Date] = #3/3/2008#"

Any ideas here? I wish to run about 20 reports based on the same date and
this would let me automate the process and not require the user to
[Enter_Date] 20 times. I am using Access 2007 on XP.

Thanks,
Mike P
 
D

Douglas J. Steele

Create an unbound form, and have the user input the date on that form. Put a
command button on the form to open the reports.

Change the queries upon which your reports are based to refer to
Forms![NameOfForm]![NameOfControl] rather than [Enter_Date].
 
N

Nicholas Scarpinato

You need to change query2's parameter to use the form suggested by Douglas.
Then open that form when the database loads and run the reports based on that
date.

Mike P said:
I am using a date entered by the user. My hope is to have the user enter
the date once, the run 20 different reports based off of that date. I hope
to use the DoCmd.OpenReport 20 times having the user enter the date once.

I plan to get the date from a form. So a more exact syntax would be
something like
DoCmd.OpenReport "rptBuyReport", acViewPreview, , "[Enter_Date] = #" & _
Me!datEnterDate & "#"

It still not working. My report uses a parameter, Enter_Date. The report
record source query qry1 built off of query qry2 which also uses the
parameter Enter_Date.

Thanks for help with this!

Nicholas Scarpinato said:
One question, before I can really help much... are you using today's date, or
a specific date entered by the user? Because if you're using today's date you
could just open a hidden form when the database opens, a form with a textbox
with the DefaultValue set to 'Format(Now(),"Short Date")', and then use the
date stored in that form to run your reports.

Mike P said:
I have a report that has the parameter [Enter_Date]. The report also calls a
query which has a parameter [Enter_Date]. When I run the report, a
parameter windows pops us, I enter the date, and the report runs fine.
However, I am now trying to run this report from a program, without prompting
the user. I am not have any luck and am wondering if I am entering the
syntax wrong as the window still pops up asking for the Enter_Date
paramenter. The syntax I am using is:

DoCmd.OpenReport "rptBuyReport", acViewPreview, , "[Enter_Date] = #3/3/2008#"

Any ideas here? I wish to run about 20 reports based on the same date and
this would let me automate the process and not require the user to
[Enter_Date] 20 times. I am using Access 2007 on XP.

Thanks,
Mike P
 

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