Open Exclusive Test in Code

crmarrio

Registered User.
Local time
Today, 02:54
Joined
Feb 5, 2002
Messages
17
I have a multi-user database that contains several tables containing static reference data.

The reference data comes from a large Oracle DB, and for ease of speed, the Access DB has local tables made.

When I want to refresh the local tables, I have a macro "Update from Oracle" to run. It's a macro, but could be converted to VBA if needed.

However, I only want to be able to run this if I am the only user in the DB. Probably the best way to do is to open the DB in exclusive mode when running the update process.

The only problem then, is that I don't want (under any circumstances) the macro to run if the DB isn't open in exclusive mode.

Is there some code I can use such as:

If "MyDB.exclusive?" = yes then run macro
else msgbox "Not open in exclusive mode"
 
You could determine who is accessing the Db by interrogating the ldb file.

Here's a link to boot everyone out of the Db if needed

or this for a demo
 
You could use a custom shortcut and set the Target: field to something like this...

"C:\Program Files\Microsoft Office\Office\msaccess.exe" "C:\Access\Test.mdb" /excl /x YourMacro

This will open the "Test.mdb" db in the Exclusive mode and run the macro named "YourMacro".

Check the help files for more info on the Startup command-line options.

HTH
 

Users who are viewing this thread

Back
Top Bottom