VBA:窗体中记录源的列表
我想扫描到ADP表单中的所有RecordSource。我的一个表单可能会调用错误的视图。它通常在RecordSource属性中设置。问题是我的ADP中大约有300多个表单。所以我想打印每个表单中的所有RecordSource,以便能够发现并纠正问题。以下是我到目前为止所做的VBA:窗体中记录源的列表,vba,ms-access-2007,Vba,Ms Access 2007,我想扫描到ADP表单中的所有RecordSource。我的一个表单可能会调用错误的视图。它通常在RecordSource属性中设置。问题是我的ADP中大约有300多个表单。所以我想打印每个表单中的所有RecordSource,以便能够发现并纠正问题。以下是我到目前为止所做的 Private Sub Command1_Click() Dim sForm As String Dim obj As AccessObject, dbs As Object Set dbs = Application.
Private Sub Command1_Click()
Dim sForm As String
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
Dim cCount As Long
cCount = 0
For Each obj In dbs.AllForms
' Print name of obj.
sForm = "Form_" & obj.name
Debug.Print cCount & " " & Forms(sForm)!RecordSource
cCount = cCount + 1
Next obj
End Sub
错误是Access找不到表单。运行时错误“2450”。可能是:
For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign
Set frm = Forms(obj.Name)
Debug.Print cCount & " " & frm.RecordSource
cCount = cCount + 1
DoCmd.Close acForm, obj.Name, acSaveNo
Next obj