vba检查子窗体是否在屏幕上

时间:2017-12-07 15:10:38

标签: access-vba

我想调用一个更新子窗体内容的函数,只有在屏幕上显示特定子窗体时才会这样。我用 .IsLoaded 试了一下,但这似乎不起作用。至少不是这样的:

EXPDP system/password@instance FULL=Y DIRECTORY=TRPROD_EXPORT DUMPFILE=TRPROD_FULL_EXPORT.DMP LOGFILE=TRPROD_FULL_EXPORT.LOG COMPRESSION=all

不幸的是每次更新mainform时都会调用子表单。我怎么能纠正这个?感谢帮助。 最好的祝福, 埃里克

1 个答案:

答案 0 :(得分:0)

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject

' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
    If obj.IsLoaded = True Then
        'Debug.Print obj.Name
        If obj.Name = "frmSubform" Then    'your main form
            If Forms!frmSubform!sfrmSubform.Form.Visible Then    'subform
                'Debug.Print "visible"
                 'do something.
            Else
                'Debug.Print "not visible"
            End If
        End If
    End If
Next obj

Set dbs = Nothing