2010年5月17日星期一

ACCESS窗体打开时检测其它窗体是否有打开

ACCESS窗体打开时检测其它窗体是否有打

公用模

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

用:

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("main") Then
MsgBox "
从主面板登", vbCritical, "提示"
Cancel = True
End If
End Sub