stopping users opening database more than 1

ryetee

Registered User.
Local time
Today, 07:57
Joined
Jul 30, 2013
Messages
952
I've spent absolutely ages looking at this and everyone seems to rave about winCheckMultipleInstances

This however doesn't work for me on Access 2010 and I can't find out if it actually should or not.

I don't really understand the code other that it seems to be searching for the caption - this is always = "" when I step through the code.

Any ideas
 
without knowing what your code is - no
 
found an article by the author saying that his code will not work from access 2007 onwards so looking for something else now...
 
a certain database?

force them to log in as a user, and do not allow multiple logins for a given user. Software solution though, not a system solution.
 
a certain database?

force them to log in as a user, and do not allow multiple logins for a given user. Software solution though, not a system solution.

Actually got some code which I think works. Will report back once tested.
I have got them signing on as users but it's a level or 2 down from the main form. Crazy I know but there is logic behind it!
 
Setting the front end up for exclusive access works for my users. Only one front end can be opened on each computer.
 
Setting the front end up for exclusive access works for my users. Only one front end can be opened on each computer.

isn't this done at run time with something like /excl in which case i have users who'll find their front end and run it themselves or open access and then open their front end from within there
 
In the end I found someone called TheSmileyCoder asking the same question as me on another forum. With a bit of detective work found him on here called, you've guessed it, the TheSmileyCoder.

I asked him if he'd found a solution to the problem he posed a few years ago and he had and just got around to posting it on his blog, http://thesmileycoder.com/stop-or-check-multiple-instances-of-access-on-startup/ , less than a week ago!

The code didn't quite work for me but after a quick tweak it did. I got rid of Private Sub Form_Timer(), changed Public Sub CheckMultipleInstances() into a function, put it into a module, and called it (=CheckMultipleInstances()) from autoexec. I also had to change the DoCmd.Quit to Application.Quit. The code that works for me is..


'*************************************
Private Declare Function apiIsIconic Lib "user32" Alias "IsIconic" (ByVal hwnd As Long) As Long
Private Declare Function apiShowWindowAsync Lib "user32" Alias "ShowWindowAsync" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Boolean
Private Const sw_Restore As Long = 9
Private Const sw_Show As Long = 5
'

Public Function CheckMultipleInstances()
Dim appAccess As Access.Application
Set appAccess = GetObject(CurrentProject.FullName)
If appAccess.hWndAccessApp = Application.hWndAccessApp Then
'Same instance. Proceed
Else
MsgBox "You allready have an instance of " & CurrentProject.Name & " running"
'Active the other access app
ActivateAccessApp appAccess.hWndAccessApp
'Clear reference to it
Set appAccess = Nothing

'Close down this app
' DoCmd.Quit
mblnClose = True
Application.Quit
End If
Set appAccess = Nothing
End Function


Public Sub ActivateAccessApp(hWndApp As Long)
If apiIsIconic(hWndApp) Then
apiShowWindowAsync hWndApp, sw_Restore
Else
apiShowWindowAsync hWndApp, sw_Show
End If
End Sub

Thanks TheSmileyCoder!!
 
does it actually work, i'm usin a2013 and i cannot open another instance of my db, with or without this code.
 
does it actually work, i'm usin a2013 and i cannot open another instance of my db, with or without this code.

I'm using 2010 and yes it does work BUT, if you just double click on the accdb then another instance isn't started. However if you have an instance open and you actually open access itself and from there try an open another instance the code will not allow you.
 

Users who are viewing this thread

Back
Top Bottom