Exclusive Access Question

  • Thread starter Thread starter Andre Laplume via AccessMonster.com
  • Start date Start date
A

Andre Laplume via AccessMonster.com

I got some helpfull tips on opening to open a db exclusively. The first
was to go to the TOOLS then OPTIONS then ADVANCED tab and click: EXCLUSIVE.
I have had mixed luck with this. My question is, by doing this I am setting
MS Access to open ALL data bases that 'I' open on my pc to open exclusively
correct? I want the db to open exclusively 'regardless' of who opens it.

A second option was to add '\excl' to the properties on a desktop shortcut
for users. However if a user does not use the short cut to get into the db
then it would not be opened exclusively.

Surely there is a simple to adjust a setting or do something such that when
a particular db is opened by some one...no one else can get in.


Am I crazy?
 
Andre,

Look again! There was a third option!

Also, don't post a new question! If none of the provided solutions meet your
needs, others can chime in to help work on a solution that does.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Sorry about the new topic...

I tried the 3rd option...the code listed does not work, it errors out.
 
Andre,

I have code that works, but I don't have it with me right now. If any of the
other MVPs are listening, can you provide Andre with some user roster code
please, or better still, a worked solution?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
THANKS! I think I am going to do what I should have done all along. Make
a copy of my original DB (call it DBOriginal.mdb) and call it DBUser (ie
DbUser.mdb). Then delete the tables in DBUser.mdb and LINK them to
DBOriginal.mdb. Then open DBOriginal and delete everything but the tables.
Then park DBOriginal on the share and install DBUser on each of the 6 users
PCs. I think this will eliminate my need for exclusive access. I think
the only downside is if I want to make some design changes to DBUser...then
when I make those changes I must reinstall DBUser on the user pcs. Sound
good?
 
Andre,

Here's some code I just knocked up. Add it to a standard module.
Then create a new macro, called "AutoExec", the first line of which should
be a RunCode action, with the following as the function name argument:
LimitUsers(1)

'Add this code to a standard module
Private Const JET_SCHEMA_USERROSTER =
"{947bb102-5d43-11d1-bdbf-00c04fb92675}"

Public Function LimitUsers(iNumber As Integer) As Boolean
'Compare the number of database users to a provided number,
'and if greater, shutdown the current database instance.

Dim rs As ADODB.Recordset
Dim iCtr As Integer

'Make sure the programmer allows at least one user.
If iNumber = 1 Then iNumber = 2

'Open the roster.
Set rs = CurrentProject.Connection.OpenSchema( _
adSchemaProviderSpecific, , JET_SCHEMA_USERROSTER)

'rs.RecordCount doesn't work reliably here, so we need to cycle
'through the recordset to count the number of users.
Do While Not rs.EOF
iCtr = iCtr + 1
'If the number of users exceeds iNumber, then shutdown the
'current database instance.
If iCtr > iNumber Then GoTo Proc_Shutdown
rs.MoveNext
Loop

'Clean up
rs.Close
Set rs = Nothing
Exit Function

Proc_Shutdown:
'Clean up before shutting down the current database instance.
rs.Close
Set rs = Nothing
Application.Quit
End Function

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Oh, I forgot, you'll need to add a reference to Microsoft ActiveX Data
Objects 2.x Library.

From a code module, Tools --> References

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
Back
Top