Results 1 to 5 of 5

Thread: Report Names

  1. #1
    Join Date
    Jan 2004
    Location
    Toronto, Canada
    Posts
    259

    Unanswered: Report Names

    How do you populate a combo box with the report names in an access mdb? For e.g if i have 2 reports in my database names "report1" and "report2", i want the combobox to display the two report names

    Report1
    Report2

    thx
    Jerry

  2. #2
    Join Date
    Jan 2004
    Location
    Vancouver, WA
    Posts
    41

    Re: Report Names

    This should work. It returns a semi-colon delimited string of all reports in the database. You could add a Replace in the iteration to remove any prefixes you may use in your report names (like "rpt"). Also, don't forget to clean up your references.

    Code:
    Private Function ListReports() As String
        Dim db1 As Database
        Dim ctr1 As Container
        Dim rpt1 As Document
        Dim strTemp As String
        
        Set db1 = CurrentDb
        Set ctr1 = db1.Containers!Reports 'Get the report container
        
        For Each rpt1 In ctr1.Documents 'Iterate reports collection
            strTemp = strTemp & rpt1.Name & ";"
        Next
        
        If strTemp <> "" Then strTemp = Left(strTemp, Len(strTemp) - 1) 'Remove the last semicolon
        ListReports = strTemp
    End Function

  3. #3
    Join Date
    Jan 2004
    Location
    Toronto, Canada
    Posts
    259
    Thx! wORKS amazing!

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Report Names

    Originally posted by Jerrie
    How do you populate a combo box with the report names in an access mdb? For e.g if i have 2 reports in my database names "report1" and "report2", i want the combobox to display the two report names

    Report1
    Report2

    thx
    Jerry
    Try this as RowSource of your ListBox

    SELECT MSysObjects.Name, MSysObjects.Flags, MSysObjects.Type
    FROM MSysObjects
    WHERE (((MSysObjects.Type)=-32764))
    ORDER BY MSysObjects.Name;

  5. #5
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    The use of msysobjects and other sys tables are not documented/supported by M$ using this may not be upgradable....

    Regards

Posting Permissions

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