2012-07-20 75 views
3

如何检索MS-Access数据库中所有表单的列表?检索Access数据库中的表单列表

要检索我用这个的所有表的列表:

For Each TDef In CurrentDb.TableDefs 
    If Left(TDef.Name, 4) <> "MSys" And Left(TDef.Name, 7) <> "~TMPCLP" Then 
     Debug.Print TDef.Name 
    End If 
Next 

另见this issue

但我不能这样做的形式。

回答

5

您可以使用AllForms获取名称列表。这些不是表格的实例,只是名称。

Sub ListForms() 
Dim frm As Object 
Dim LiveForm As Form 

    For Each frm In CurrentProject.AllForms 
     Debug.Print frm.Name 
     ''To use the form, uncomment 
     ''DoCmd.OpenForm frm.Name, acViewDesign 
     ''Set LiveForm = Forms(frm.Name) 
     ''Do not forget to close when you are done 
     ''DoCmd.Close acForm, frm.Name 
    Next 
End Sub 
+0

非常好!谢谢 – waanders 2012-07-20 09:24:03

+0

我必须使用'Dim frm As AccessObject'来使它运行 – waanders 2012-07-20 09:26:05

+0

我该如何检索窗体的标题? 'Debug.Print frm.Properties(“Caption”)'不起作用 – waanders 2012-07-20 11:22:55