office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

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

2018-12-04 14:36:00
tmtony8
原创
6589

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


    分享