titan2000_99
03-09-2001, 12:20 PM
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
03-09-2001, 01:15 PM
Try this (the VBA way)
dim rpt as reports
for each rpt in Me
docmd.openreport rpt.name
DoEvents
next
R. Hicks
03-11-2001, 09:01 PM
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
03-27-2001, 05:35 AM
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