Print all reports from a form (1 Viewer)

T

titan2000_99

Guest
Hi, I have a form with a list box that lists all the names of the reports. I want to create a button "Print All Reports" that print all the reports. What should I write in the on_click event? Should I use something like:

Dim rpt as Reports
for each rpt in currentdb.reports
rpt.print()
next rpt

I tried the above and it generates a compile error "Method or data member not found" for the "currentdb.reports".

Please help! Thanks.
 

llkhoutx

Registered User.
Local time
Today, 14:49
Joined
Feb 26, 2001
Messages
4,018
Try this (the VBA way)

dim rpt as reports

for each rpt in Me
docmd.openreport rpt.name
DoEvents
next
 

R. Hicks

AWF VIP
Local time
Today, 14:49
Joined
Dec 23, 1999
Messages
619
Maybe this will help you. This code is for Access 97, it will need to be altered to work in Access 2000:

Private Sub cmdPrintAll_Click()
Dim dbs As Database
Set dbs = CurrentDb
Dim ctr As Container
Dim doc As Document
Dim strDocName As String

Set ctr = dbs.Containers("Reports")

For Each doc In ctr.Documents
  strDocName = doc.name
  DoCmd.OpenReport strDocName ' Add any arguments needed
Next
End Sub

HTH
RDH

[This message has been edited by R. Hicks (edited 03-11-2001).]
 

Blkblts

Registered User.
Local time
Today, 14:49
Joined
Jan 21, 2000
Messages
61
Thanks R. Hicks I have the 2000 code but was looking for the 97 code to create a list box listing all the reports available. Here is the 2000 code for anyone who may searching for it....

Private Sub Form_Load()
Dim objAO as AccessObject
Dim objCP as Object
Dim strValues As String

Set objCP = Application.CurrentProject
For Each objAO in objCP.AllReports
strValues = strValues & objAO.name & ";"
Next objAO
'Assumming you have a list box on form called lstReports
lstReports.RowSourceType = "Value List"
lstReports.RowSoruce = strValues
End Sub

Kim
 

Users who are viewing this thread

Top Bottom