I have a button to lock unlock a form with a subform. To enable the button I would like to set a password with a msgbox. But I have an issue in my code.
I first use the code to show the password msgbox with conditional, if the password is right the user locks/unlocks the forms. But I have end with statement in wrong place.
Private Sub bloquear_Click()
With Me.bloquear
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
End If
If strPasswd = "Password" Then
If .Caption = "Unlock" Then
Me.AllowAdditions = True
Me.AllowEdits = True
Me.CONSULTA_PRODUCTOS.Form.AllowAdditions = True
Me.CONSULTA_PRODUCTOS.Form.AllowEdits = True
.Caption = "Lock"
Else
Me.AllowAdditions = False
Me.AllowEdits = False
Me.CONSULTA_PRODUCTOS.Form.AllowAdditions = False
Me.CONSULTA_PRODUCTOS.Form.AllowEdits = False
.Caption = "Unlock"
Me.Refresh
End If
End With
Else
MsgBox "Sorry, you do not have access to this form", _
vbOKOnly, "Important Information"
Exit Sub
End If
End Sub
The msgbox shows
Compile error, end with without with
I don't know what is wrong because the with is there.
Thanks