PDA

Click to See Complete Forum and Search --> : Report Count not working


Hollie
Nov 21st, 2000, 05:11 AM
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.

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

paulw
Nov 21st, 2000, 05:51 AM
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.

Hollie
Nov 21st, 2000, 05:57 AM
Thanks

It worked a treat!