VBA:表单中的记录源列表

发布于 2024-12-09 12:19:43 字数 606 浏览 0 评论 0原文

我想扫描到 ADP 表单中的所有 RecordSource。我的其中一个表单可能会调用错误的视图。它通常在 RecordSource 属性中设置。问题是我的 ADP 中有大约 300 多个表格。所以我想打印每个表单中的所有 RecordSource 以便能够找到并纠正问题。这是我到目前为止所做的事情。

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 找不到 Form。运行时错误“2450”。

I want to scan to all RecordSource 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'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷离° 2024-12-16 12:19:43

也许:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文