Access Application Question (1 Viewer)

BrotherBook

Registered User.
Local time
Today, 06:17
Joined
Jan 22, 2013
Messages
43
Hi-

I've created a front end application using Access with a SQL back end. I have a shortcut to my application on each user's desktop, which references the application stored in their My Documents folder. I am trying to find a way to limit the users to only having one instance of the application open as the code breaks if they have more than one open.

Is there a way I can do this?

Thanks,
Mike
 

way2bord

Registered User.
Local time
Today, 03:17
Joined
Feb 8, 2013
Messages
177
A few ways to manage this...

1. Change your shortcut to a short script with a simple conditional check if MS access is already open.

2. A new table that creates a simple binary check that is flipped on when someone logs on and off when someone logs off. On logging in, the application first checks the switch - if it's already on, the application immediately quits.

There's a couple other ways, but these are generally the easiest to implement.
 

Simon_MT

Registered User.
Local time
Today, 11:17
Joined
Feb 26, 2007
Messages
2,177
I found this along time ago:

Code:
Function IsRunning() As Integer

'    DoCmd.Maximize
    
 Dim db As DAO.Database
    Set db = CurrentDb()
    
    If IsRunningDDELink(db.Name) Then
        MsgBox "The database is already open"
        Application.Quit
        Set Application = Nothing
    End If
End Function

Code:
Private Function IsRunningDDELink(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
       IsRunningDDELink = False
    Else
        IsRunningDDELink = True
        DDETerminate varDDEChannel
        DDETerminateAll
    End If
    Application.SetOption ("Ignore DDE Requests"), False
End Function

Simon
 

Users who are viewing this thread

Top Bottom