Access获取对象中的所有报表名

2018-12-04 14:36:00
黄善超
原创
151

有网友的程序中有若干个报表,其中所有报表都有共同的字段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


    分享