M
mdmckin
I'd like to detect if a form is open, I want only one person to have
this form at a time. The form uses temporary data to fill in a few
fields on reports and gets cleared after each use.
The following code works, but only within the same instance of Access,
if I have the form open on one client and then try to open up the same
form within the same database from a different client, it doesn't
work.
In a module:
Public Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
And in a test form with a command button:
Private Sub Command0_Click()
fIsLoaded "JobPacket"
Dim strMsg As String
strMsg = "Form is already opened by another user,"
strMsg = strMsg & vbCrLf & vbCrLf & "Please try again later."
If fIsLoaded("fJobPacket") = True Then
MsgBox (strMsg)
Else
DoCmd.OpenForm "fJobPacket"
End If
End Sub
What would need to be done differently to make this work in a multi-
user environment?
Thanks!
Mark
this form at a time. The form uses temporary data to fill in a few
fields on reports and gets cleared after each use.
The following code works, but only within the same instance of Access,
if I have the form open on one client and then try to open up the same
form within the same database from a different client, it doesn't
work.
In a module:
Public Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
And in a test form with a command button:
Private Sub Command0_Click()
fIsLoaded "JobPacket"
Dim strMsg As String
strMsg = "Form is already opened by another user,"
strMsg = strMsg & vbCrLf & vbCrLf & "Please try again later."
If fIsLoaded("fJobPacket") = True Then
MsgBox (strMsg)
Else
DoCmd.OpenForm "fJobPacket"
End If
End Sub
What would need to be done differently to make this work in a multi-
user environment?
Thanks!
Mark