How do I lock out users if am in the database in Access?

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

Guest

I am trying to keep other backend users out of the database once I enter it.
Is thier a way of doing this.
 
Schulfer said:
I am trying to keep other backend users out of the database once I
enter it. Is thier a way of doing this.

Open it exclusively. It's an option in the file open dialog.
 
To open the back end exclusively in code from the front end put a module
along these lines in the front end:

''''module begins''''
Option Compare Database
Option Explicit

Dim dbs As DAO.Database
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub LockBackend(strPath As String)

On Error GoTo Err_Handler

Set dbs = OpenDatabase(strPath, True)

Exit_Here:
Set dbs = Nothing
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_Here

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub UnlockBackEnd()

On Error GoTo Err_Handler

Const NO_REF_TO_BACKEND = 91

'On error resume next
dbs.Close

Exit_here:
Set dbs = Nothing
Exit Sub

Err_Handler:
Select Case Err.Number
Case NO_REF_TO_BACKEND
' do nothing
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select
Resume Exit_here

End Sub
''''module ends

Ken Sheridan
Stafford, England

To 'lock' the back end, which you can either do when the front end starts up
or whenever you want to edit data, e.g. when a bound form is opened, call the
LockBackEnd procedure, passing the path to the back end into it:

LockBackEnd "F:\SomeFolder\SomeSubFolder\SomeDatabase.mdb"

to unlock it call the UnlockBackEnd procedure:

UnlockbackEnd
 
Just to add more specific instructions.

Open Access
Go to the File menu, Choose Open
Find and SINGLE click the file you want to open
On the right side of the open button at the bottom right, there is a
small down arrow. Click the down arrow, not the word "Open".
Choose open exclusive.

Keven
 
PS: The commented out 'on error resume next' line in my reply was because I
first thought of using inline error handling, but then decided to branch to
an error handler instead. Omitted to delete the line.

Ken Sheridan
Staford, England
 
if you had enough balls to be using SQL Server; it would be quite easy.


you could merely kill connections lol

MDB is for babies.

Access Data Projects won the war.

-Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top