Link to home
Start Free TrialLog in
Avatar of browsen
browsen

asked on

Disable Bypass Key (again)

I have a really great module for disabling the bypass key which I aquired right here at experts exchange.  Its in two parts, part one the module:

Option Compare Database
Option Explicit

Public Function SetProperties(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer

On Error GoTo Err_SetProperties

Dim db As DAO.Database, prp As DAO.Property

        Set db = CurrentDb
            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
        Resume Next
    Else
        SetProperties = False
        MsgBox "SetProperties", Err.Number, Err.Description
    Resume Exit_SetProperties
End If
End Function

and part two the command button that fires it:

Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
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 = "joy" 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 "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub

This has worked great for me in the past and I'm attempting to use it in a new database but I get an error when I try to compile on this line in the module
Dim db As DAO.Database, prp As DAO.Property
the error says user define type not defined.

Any idea what the problem is?  
I'm thinking I failed to reference a library but I don't know which one or if thats even close to the answere.

Please Help!
ASKER CERTIFIED SOLUTION
Avatar of Jeremyw
Jeremyw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BillPowell
BillPowell

Jeremy is right, In Access 2000 and above, a DAO reference does not get turned on by default, as it is replaced with ADO.  Setting the reference should fix it.
Avatar of browsen

ASKER

Thanks A Bunch Jeremy!

I kinda figured it was a missing reference but I would never remembered which one.  Thanks for the help!

PS

Does anyone besides me wish that EE would go back to the "old look"?
Thanks for the ? browsen

"Does anyone besides me wish that EE would go back to the "old look"?"

It will :)  http://oldlook.experts-exchange.com

Jeremy
Avatar of browsen

ASKER

Well I'll be (insert curse word here)!

Thanks Jeremy I like this view ALOT better!
No problem.  I've finally gotten used to the new look.  Still like some things about the old way though.

Jeremy