Results 1 to 9 of 9

Thread: Why doesn't this work??

  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 crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Code:
    Dim x As New Access.Application
    Dim obj As AccessObject, dbs As Object
        x.OpenCurrentDatabase "c:\db1.mdb"
        Debug.Print x.CurrentProject.AllReports.Count

    hth
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    Sorry but currentproject isn't recognised.

    What I'm trying to do is display a list of all available reports so that users can click on them and open them.

    If I manually fill the list the program works but what I want to do is get the names of all available records and fill the list using a loop rather than hard code

    do you have any ideas?
    Just trying to muddle through...

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    What version of access?
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Hollie,

    read my post in the Database thread. Key is to use the Documents in the Containers collection. Reports collection is the OPEN reports only.

    Cheers,

    P.
    Not nearly so tired now...

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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    Thanks for all your help guys!

    Hollie
    Just trying to muddle through...

  7. #7
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Hollie,
    This works fine on my machine, Except it lists the reports in reverse order (shouldn't be too difficult to solve)
    Using ACCESS 2000, via the 9.0 Object Lib
    Code:
    Private Sub Command1_Click()
    ' Initialise list of reports
    
    Dim temp As Integer
    Dim temploop As Integer
    Dim Y As Object
    Set ErrReport = CreateObject("Access.Application")
    ErrReport.OpenCurrentDatabase "C:\db1.mdb"
    For Each Y In ErrReport.CurrentProject.AllReports
        List1.AddItem Y.Name
    Next Y
    
    End Sub
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  8. #8
    Guest
    Originally posted by crispin
    Hollie,
    ...Except it lists the reports in reverse order (shouldn't be too difficult to solve)...
    Code:
    ...
        List1.AddItem Y.Name
    ...
    Try this:

    Code:
    ...
        List1.AddItem Y.Name , 0
    ...

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    Thanks for all your help guys - I have now got it working!

    H.
    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