J
John
Hi,
I have found several methods to implement a form which will secure/unsecure
my DB.
However, I am struggling to make this work.
I am using access 2007, would this make a difference?
Any help here would be most appreciated.
Code to Secure is
------------------
Public Function SetAllowBypassKeyFalse()
On Error GoTo Err_SetAllowBypassKeyFalse
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties("AllowBypassKey") = False
Set db = Nothing
Exit_SetAllowBypassKeyFalse:
Exit Function
Err_SetAllowBypassKeyFalse:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, False)
db.Properties.Append prp
Resume Next
Else
MsgBox "SetAllowBypassKeyFalse", Err.Number, Err.Description
Resume Exit_SetAllowBypassKeyFalse
End If
End Function
---------------------
Code to UnSecure is
---------------------
Public Function SetAllowBypassTrue()
On Error GoTo Err_SetAllowBypassKeyTrue
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties("AllowBypassKey") = True
Set db = Nothing
Exit_SetAllowBypassKeyTrue:
Exit Function
Err_SetAllowBypassKeyTrue:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, True)
db.Properties.Append prp
Resume Next
Else
MsgBox "SetAllowBypassKeyFalse", Err.Number, Err.Description
Resume Exit_SetAllowBypassKeyTrue
End If
End Function
I have found several methods to implement a form which will secure/unsecure
my DB.
However, I am struggling to make this work.
I am using access 2007, would this make a difference?
Any help here would be most appreciated.
Code to Secure is
------------------
Public Function SetAllowBypassKeyFalse()
On Error GoTo Err_SetAllowBypassKeyFalse
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties("AllowBypassKey") = False
Set db = Nothing
Exit_SetAllowBypassKeyFalse:
Exit Function
Err_SetAllowBypassKeyFalse:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, False)
db.Properties.Append prp
Resume Next
Else
MsgBox "SetAllowBypassKeyFalse", Err.Number, Err.Description
Resume Exit_SetAllowBypassKeyFalse
End If
End Function
---------------------
Code to UnSecure is
---------------------
Public Function SetAllowBypassTrue()
On Error GoTo Err_SetAllowBypassKeyTrue
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties("AllowBypassKey") = True
Set db = Nothing
Exit_SetAllowBypassKeyTrue:
Exit Function
Err_SetAllowBypassKeyTrue:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, True)
db.Properties.Append prp
Resume Next
Else
MsgBox "SetAllowBypassKeyFalse", Err.Number, Err.Description
Resume Exit_SetAllowBypassKeyTrue
End If
End Function