-
Heres my code to generate the list of reports.
I get nothing out and temp = 0 but I have three reports!!
can anyone help?
:confused: H.
Code:
Private Sub Form_Load()
' Initialise list of reports
Dim temp As Integer
Dim temploop As Integer
Set ErrReport = CreateObject("Access.Application")
ErrReport.OpenCurrentDatabase "C:\db1.mdb"
temp = ErrReport.Reports.Count
For temploop = 0 To temp - 1
lstReports.List(temploop) = ErrReport.Report(temploop).Name
Next
End Sub
-
The reports collection is only OPEN reports. Use the containers collection instead and look for report type documents.
i.e.
Dim db As Database, ctr As Container, doc As Document
' Return reference to current database.
Set db = CurrentDb
' Return reference to Reports container.
Set ctr = db.Containers!Reports
' Enumerate through Documents collection of Reports container.
For Each doc In ctr.Documents
' Do something with the reports...
lstReports.AddItem doc.Name
Next
etc.
Cheers,
P.
-
Thanks
It worked a treat!