Report parameters from Docmd

obiron

New member
Local time
Today, 11:51
Joined
Jun 30, 2008
Messages
6
Hi guys, I am sure this has probably been asked a thousand times but..

I have a simple access app that I have been using on my own and now I need to make functions availalble to less experienced users.

I have a report that is built from a query (I learned long ago not to build reports on tables!)

The query takes three parameters to apply a filter (the WHERE clause): [shop],[year] and [week]

This report get run from a number of places (I run it manually and I now need to automatically output the report from a form)

I want to print the report using 'DoCmd.OutputTo acReport' because I want to format it as Snapshot. How can I pass the report parameters to the report from the DoCmd function, I would rather not re-write the query to take param values from a form, nor apply filter criteria to the report.

To make things harder (or easier depending on how you look at it) I also want the parameters to affect the output path and filename for the snapshot file.

I will be putting these param values into a form, but what is the most effective way to use them.

TIA

Obiron
 
It's easier than you think, replace those parameters, with the names of controls on the form, they can be simple text boxes or combos that select data...

Now the syntax to replace you [Square bracket params] is this...

Simple:
forms![YourformName]![YourcontrolName]

better if you want a field to be optional.... place a "*" in the controls default value property
Like(forms![YourformName]![YourcontrolName])& "*"

for the export it will work the same, in either case the query looks to the form, so for printing (just print the report) or exporting you just need to trigger it, the export will need something more, but I will post that tomorrow as I don't want to put the wrong syntax
 

Users who are viewing this thread

Back
Top Bottom