Stop access database being opened a second time

D

Diarmuid

Hi
If a user already has my frontend opened on their pc, I want a message
to appear when they open it a second time. How can I check for this?
Thanks
Diarmuid
 
M

Mike Labosh

If a user already has my frontend opened on their pc, I want a message
to appear when they open it a second time. How can I check for this?

A Mutex Question! These are always fun!

"Mutex" stands for "Mutually Exclusive". In the WIN32 API SDK, a Mutex is a
system-level resource that can only be held by one process. To accomplish
what you want, you can have your startup code create a mutex with a specific
hard-coded name, and hold the Mutex's handle in a public global variable.
Then your shutdown code passes that handle back to windows to release it.
Then, when a user starts a second instance of your application, the new call
to CreateMutex() fails, and you can MsgBox the user and quit. The only
catch is that if you're in the VBA debugger and "reset" your code, you lose
the mutex handle and will be unable to release it. Lookup these two
functions in MSDN:

CreateMutex()
ReleaseMutex()
 
T

Tony Toews

Mike Labosh said:
A Mutex Question! These are always fun!

"Mutex" stands for "Mutually Exclusive". In the WIN32 API SDK, a Mutex is a
system-level resource that can only be held by one process.

I've heard of these before. Thanks, these could be quite handy for
some utilities I'll be working on.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
T

Tony Toews

Mike Labosh said:
A Mutex Question! These are always fun!

"Mutex" stands for "Mutually Exclusive". In the WIN32 API SDK, a Mutex is a
system-level resource that can only be held by one process.

I've *never* heard of these before. Thanks, these could be quite
handy for some utilities I'll be working on.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Top