Question : Disable Shift ByPass Key = Error Message

I'm using Access 2003.  I copied this code which I obtained off of this sight.  When I run the click event I receive a pop-up error message "Complile: Syntax Error" and it highlights the first MsgBox code.  Per the instructions I have Microsoft DAO 3.6 turned on.

What is the fix for this?   Are there any potential errors with the second 'Else' MsgBox.

Thanks,
Lee

BUTTON = Disable ByPass Key
Private Sub bDisableBypassKey_Click()  *** On click code stops and highlights this in YELLOW
 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")
   '**** ENTER YOUR PASSWORD HERE *****
    If strInput = "MyPassWord" Then
        SetProperties "AllowBypassKey", dbBoolean, True
        Beep
**** RECIEVE A "COMPILE: SYNTAX ERROR" POP-UP WITH THIS MSGBOX TEXT HIGHLIGHTED
        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 Sub
************************************
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

Answer : Disable Shift ByPass Key = Error Message

Change this piece...
**** RECIEVE A "COMPILE: SYNTAX ERROR" POP-UP WITH THIS MSGBOX TEXT HIGHLIGHTED
        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"

To this:
**** RECIEVE A "COMPILE: SYNTAX ERROR" POP-UP WITH THIS MSGBOX TEXT HIGHLIGHTED
        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"


Fully updated code in snippet.

-Sean Strickland

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
Private Sub bDisableBypassKey_Click()  *** On click code stops and highlights this in YELLOW
 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")
   '**** ENTER YOUR PASSWORD HERE *****
    If strInput = "MyPassWord" Then
        SetProperties "AllowBypassKey", dbBoolean, True
        Beep
**** RECIEVE A "COMPILE: SYNTAX ERROR" POP-UP WITH THIS MSGBOX TEXT HIGHLIGHTED
        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 Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us