Determine if current database is open exclusively.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there any a nice and clean way via VBA to determine if the current user
has opened the database exclusively?

I have had a problem with the Jet User Roster schema not working when I have
passed the /Excl command line switch (error 3251 - Object or Provider is not
capable of performing requested operation). I can catch this command line
switch without a problem, but I want to cover the possibility that a user has
opened the database exclusively from the File > Open menu option.

Cheers,

Stuart
 
Hi, Stuart.
Is there any a nice and clean way via VBA to determine if the current user
has opened the database exclusively?

I'd put in error handling to catch the 3251 error whenever it happens, but
if you'd like another function to do the checking, then create a function
that uses the OpenDatabase( ) method to open the database in shared mode.
Create an error handler for this function that handles error numbers 3051 and
7866. If either of these error numbers are encountered while opening the
database programmatically, then the database is either open exclusively or
the specific file doesn't exist.

If by "current user" you mean the user who has opened the database needs to
check the current database, then the OpenDatabase method should be used
within a separately created Workspace object, not the default Workspace
object. If, on the other hand, the "current user" is any user who has a
database file open that you'd like to check, then the OpenDatabase( ) method
can be used in the default Workspace, as long as no database objects are
going to be modified and saved while the second database is open in shared
mode.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
Hi,

I'd tried that and although it works fine I was kind of hoping there may
have been a property exposed somewhere or the other. You've saved me hours of
pointless searching tho'... ;)

Cheers,

Stuart
 
Back
Top