I have the following code to protect a form:
If InputBox(“Password?” <> “Oscar” Then
MsgBox "You are not authorized to open this form”
Cancel = True
End If
However if I type "oscar" it still opens. How do I make it look for "Oscar"?
I have the following code to protect a form:
If InputBox(“Password?” <> “Oscar” Then
MsgBox "You are not authorized to open this form”
Cancel = True
End If
However if I type "oscar" it still opens. How do I make it look for "Oscar"?
Private Sub Form_Open(Cancel As Integer)
Dim LResult As Integer
LResult = StrComp(InputBox("Password"), "Oscar", vbTextCompare)
If LResult = 0 Then
MsgBox "You are authorized to open this form"
Else
MsgBox "You are not authorized to open this form"
Cancel = True
End If
End Sub
The above code is still comparing Oscar and oscar as equal
Put vbBinaryCompare instead of vbTextCompare
i'm under thinking this i think
t= inputbox("Enter Password")
if t <> "Oscar" then
else
end if
or
if inputbox("Enter Password") <> "Oscar" then exit sub else docmd.openform "your form"