By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Prevent Access DB from being opened twice

P: n/a
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?

TIA

Doug
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"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

--------------
Nov 13 '05 #2

P: n/a
Douglas wrote:
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?

TIA

Doug


An easy way to do this is to select Tools/Options/Advanced/Exclusive for
the front-end database. (Presumably your users don't open the back end
directly).

This will continue to work if you put the back end on the network, and
install copies of the front end on the local machines. If you intend to
put both front and back end on the network, the IsRunning solution
posted above is the one you want.

Nov 13 '05 #3

P: n/a
On 23 May 2004 02:39:18 -0700, Douglas wrote:
I have a frontend and backend database , program.mde and data.mdb on a
client PC.


In Form_Open of your start-up form:

If Dir(Left$(CurrentDB.Name,Len(CurrentDB.Name) -3) & "ldb") <> "" Then
MsgBox "Application already open"
DoCmd.Quit
End If

The method is fairly reliable because .ldb is always available unless the
mdb has been opened in exclusive mode.

Peter

--
No mails please.
Nov 13 '05 #4

P: n/a
Thanks guys,

I'll need to do it Peter's way as when i say network i actually meant
2 PCs file sharing!
Thanks for your time

Doug

Bruce Dodds <br********@comcast.net> wrote in message news:<tU1sc.99730$xw3.5923495@attbi_s04>...
Douglas wrote:
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?

TIA

Doug


An easy way to do this is to select Tools/Options/Advanced/Exclusive for
the front-end database. (Presumably your users don't open the back end
directly).

This will continue to work if you put the back end on the network, and
install copies of the front end on the local machines. If you intend to
put both front and back end on the network, the IsRunning solution
posted above is the one you want.

Nov 13 '05 #5

P: n/a
Douglas wrote:
Thanks guys,

I'll need to do it Peter's way as when i say network i actually meant
2 PCs file sharing!
Thanks for your time

Doug
Testing for the .ldb file would prevent two users from accessing the
data at the same time.

Bruce Dodds <br********@comcast.net> wrote in message news:<tU1sc.99730$xw3.5923495@attbi_s04>...
Douglas wrote:

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?

TIA

Doug


An easy way to do this is to select Tools/Options/Advanced/Exclusive for
the front-end database. (Presumably your users don't open the back end
directly).

This will continue to work if you put the back end on the network, and
install copies of the front end on the local machines. If you intend to
put both front and back end on the network, the IsRunning solution
posted above is the one you want.


Nov 13 '05 #6

P: n/a
"Peter Doering" <no****@doering.org> schrieb im Newsbeitrag
news:2h************@uni-berlin.de...
On 23 May 2004 02:39:18 -0700, Douglas wrote:
I have a frontend and backend database , program.mde and data.mdb on
a
client PC.


In Form_Open of your start-up form:

If Dir(Left$(CurrentDB.Name,Len(CurrentDB.Name) -3) & "ldb") <> ""
Then
MsgBox "Application already open"
DoCmd.Quit
End If

The method is fairly reliable because .ldb is always available unless
the
mdb has been opened in exclusive mode.


An ldb-file opens only if you access to data or a form is bound to a
recordset. If you have an unbound startform, this method will not work.

Peter
Nov 13 '05 #7

P: n/a
Hi Douglas

"Douglas" <do********@yahoo.com> schrieb im Newsbeitrag
news:be**************************@posting.google.c om...
Thanks guys,

I'll need to do it Peter's way as when i say network i actually meant
2 PCs file sharing!


Be careful:

-This method prevents you from opening the same frontend(!) twice from
the same pc.
-I do not know if it'l work if you open the frontend(!) from a
network-drive (you should stay away from doing this anyway) Maybe it
does-;)
-it does not prevent you from opening the backend(!) more than once.
(explorer etc)
-Opening a database exclusively does not prevent you from opening the
backend twice!

Peter
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.