AllowByPass Using ADO

Lynn_AccessUser

Registered User.
Local time
Today, 12:30
Joined
Feb 4, 2003
Messages
125
I have found examples of how to lock the db by disabling the shift key in DAO but was wondering if anyone had an example of how to do it in ADO.

I like ghudson code using a password box and was hoping someone had done it in ADO.

Thanks!!!
 
OK, I got the code to work. I will be the first to admit that I may have removed something that needs to be in the code to make it completely correct . . . but it does work.

Any suggestions to make the code even better is welcome!!!

Module:

Public Function SetProperties(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties

'Dim db As Database, prp As Property
'Dim db As DAO.Database, prp As DAO.Property
Dim prps As AccessObjectProperties
Dim prp As AccessObjectProperty
Dim isPresent As Boolean

'Set db = CurrentDb

Set prps = Application.CurrentProject.Properties
For Each prp In prps
If (StrComp(prp.Name, strPropName, vbTextCompare) = 0) Then
isPresent = True
Exit For
End If
Next

If (isPresent) Then
prps(strPropName).Value = varPropValue
Else
prps.Add strPropName, varPropValue
End If

'db.Properties(strPropName) = varPropValue
'SetProperties = True
'Set db = Nothing

Exit_SetProperties:
Exit Function

Err_SetProperties:
If Err = 3270 Then 'Property not found
'Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
'db.Properties.Append prp
Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "Runtime Error # " & Err.Number & vbCrLf & vbLf & Err.Description
Resume Exit_SetProperties
End If

End Function

Invisible Command Button:

Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click

Dim strInput As String
Dim strMsg As String
Dim dbBoolean As Boolean

Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & "Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")

If strInput = "Test" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & "The Shift key will allow the users to bypass the startup options the next time the database is opened.", vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & "The Bypass Key was disabled." & vbCrLf & vbLf & "The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", vbCritical, "Invalid Password"
Exit Sub
End If

Exit_bDisableBypassKey_Click:
Exit Sub

Err_bDisableBypassKey_Click:
MsgBox "Runtime Error # " & Err.Number & vbCrLf & vbLf & Err.Description
Resume Exit_bDisableBypassKey_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom