开发者

VBA: List of RecordSource in Form

I want to scan to all Rec开发者_如何转开发ordSource in my ADP Forms. One of my Form might call in the wrong View. It usually sets in RecordSource Property. The problem is there are about 300+ forms in my ADP. So I want to print all RecordSource in each form in able to find and correct the problem. Here are what I did so far.

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

The error is Access can't find Form. Run-Time Error '2450'.


Perhaps:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜