Access獲取對象中的所有報表名

2018-12-04 14:36:00
tmtony8
原創
1646

有網友的程序中有若干個報表,其中所有報表都有共同的字段A ,希望通過篩選A內容輸出報表

這里我們只說明如何獲取Access對象中所有報表名。如下圖,遍歷所有報表



獲取所有報名表的源碼

Sub AllReports()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentProject
    ' Search for open AccessObject objects in AllReports collection.
    For Each obj In dbs.AllReports        
            ' Print name of obj.
            Debug.Print obj.Name 
    Next obj
End Sub 


通過 列表框.AddItem 報表名 添加到列表框

Private Sub Form_Load()
    Me.List0.RowSourceType = "value list"
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentProject
    For Each obj In dbs.AllReports
        Me.List0.AddItem obj.Name
    Next obj
End Sub


    分享
    黑龙江p62开奖公告l