VBA Access 检查父表单是否存在 [英] VBA Access check if Parent form exists
问题描述
在 MS Access 中,我正在从另一个对话框窗体打开一个对话框窗体.
in MS Acces I'm opening a Dialog Form from another Dialog form.
所以formA
,打开formB
.但是他们的用户可能会以独立方式打开 formB
,我想避免在这种情况下出现错误.
So formA
, opens formB
. But they user can potentially open formB
as standalone, I would like to avoid having errors in this case.
我考虑过检查 formB
的现有父级.
I thought about checking for and Existing parent for formB
.
但是当我这样做时,我仍然收到错误 2452:您输入的表达式对 Parent 属性无效.
But when I do it I get still get the Error 2452: The expression you entered has invalid to the Parent property.
我试过了:
If Not IsError(Me.Parent) Then
Me.Parent.cboTraining.Requery
End If
和
If Not IsNull(Me.Parent) Then
Me.Parent.cboTraining.Requery
End If
推荐答案
您可以使用以下方法测试表单是否打开:
You can test if a form is open using:
If Not CurrentProject.AllForms("someFormName").IsLoaded Then
或者,当您从 formA 打开 formB 时,您可以提供一个 openArg,这很容易测试.
Alternatively, when you open formB from formA, you could provide an openArg, which is easy to test.
这篇关于VBA Access 检查父表单是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!