Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate Report Printing in Access

Status
Not open for further replies.

SpyderMan1234

IS-IT--Management
Feb 26, 2004
35
US
I have quite a few reports that need to be printed on a weekly/monthly/quarterly basis. I know how to use DoCmd to print out reports via VBA, but I don't have the time to hardcode the name of each report into the code. I wondered if there was a way of telling MS Access to print all reports without having to code the name of each individual report. Perhaps using wildcards?? What would be IDEAL is if I could even narrow it down even further and make it print all reports within a particular group. I've seen software add-ons that you can buy for $25 to do this, but I don't see why I cannot do it myself through VB. Any ideas???

Your reponse is MUCH appreciated!

Jeff
 
You can create a table with the day of week or day of month the report is schduled to print.

You can schedule the database to open with a command line to start a macro that start's the report code.

Your code could loop through the table of reports and conditionally print the report.

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
I didn't debug this, but it would look something like this:

Sub AllReports()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllReports collection.
For Each obj In dbs.AllReports
docmd.openreport obj.Name. acPrint

Next obj
End Sub

we usually use an access job running on a server that has the timer event of a form enabled to check text boxes on the form for a scheduled days and times to print the reports, with a manual override command button to send them to print. You can also set up a management form by using the same loop to automatically add new reports to a job list, with a check box to prevent unwanted reports from printing. The same job also uses the Outlook object model to attach the reports to emails to send them to people so they don't even have to be printed. Otherwise, you get screwed every time the printer jams in the middle of the night.

 
BTW- ignore the comment in the code frag above, the object does not have to be open for the code to work
 
Thanks for the tips...they were exactly what I was looking for!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top