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
"Schulfer" wrote:
> I am trying to keep other backend users out of the database once I enter it.
> Is thier a way of doing this.
|