By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Generate report for different departments in a list

P: n/a
Hi,

I have a department list query called qryDepartment. A report is
designed called rptException based on query qryException. I need to run
this report for each department in qryDepartment. The field name for
the department is fldDepartment

Can some kind soul help me with a code which I can attach to the On
Click event of a button such that reports with name Department.pdf are
created (I have Adobe Professional) and save to a directory Z:\Reports

Please let me know if I have omitted info which may be required to
assist.

TIA.

Ninad.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
hmm... so you need to run this for each department in the query.

Easiest way is probably to open a recordset based on the query, and
hten to open the report with that filter. Then you can do whatever
with the data.

something like

dim qdf as querydef
dim rst as dao.recordset
set qdf = currentdb.querydefs(strQueryName)
set rst=qdf.openrecordset
do until rst.eof
docmd.openreport "reportname", "[somefield]='" &
rst.fields("MyField") & "'"
docmd.printout
Docmd.Close "reportname",acREport
rst.movenext
loop

Hope this points you in the right direction...

Nov 13 '05 #2

P: n/a
Thanks. Once I resume office, I'll try out the above and post my
success/failure.

Ninad.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.