"Douglas" <do********@yahoo.com> schrieb im Newsbeitrag
news:be*************************@posting.google.co m...
I have a frontend and backend database , program.mde and data.mdb on a
client PC.
How do i prevent them launching the program.mde more than once on a
single PC? Somtimes they minizmise the program and dont see it and
startup an new copy.
At a later stage I want this database to be multiuser, on a network ,
so i dont want to limit the database to one user only, just one
program lauch per PC
Can it be done?
Copy the following Code into a module and call the function IsRunning.
(author unknown)
Peter
------------
Function IsRunning() As Integer
On Error GoTo PROC_ERR
Dim DB As DAO.Database
Set db = CurrentDb
If TestDDELink(db.Name) Then
("App alrey opened")
db.Close
Set db = Nothing
DoCmd.Quit
End If
Exit Function
PROC_ERR:
MsgBox "Fehler: " & Error$
Resume Next
End Function
--------------
Function TestDDELink(ByVal strAppName$) As Integer
Dim varDDEChannel
On Error Resume Next
Application.SetOption ("Ignore DDE Requests"), True
varDDEChannel = DDEInitiate("MSAccess", strAppName)
' When the app isn't already running this will error
If Err Then
TestDDELink = False
Else
TestDDELink = True
DDETerminate varDDEChannel
DDETerminateAll
End If
Application.SetOption ("Ignore DDE Requests"), False
End Function
--------------