office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

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

Access穫取對象中的所有報錶名

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

有網友的程序中有若榦箇報錶,其中所有報錶都有共衕的字段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


    分享