Results 1 to 3 of 3

Thread: Report Count not working

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96

    Angry

    Heres my code to generate the list of reports.

    I get nothing out and temp = 0 but I have three reports!!

    can anyone help?

    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
    Just trying to muddle through...

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    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.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    Thanks

    It worked a treat!
    Just trying to muddle through...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width