Hi
been trying to use VBA to password a form and found the code below.
typed it in manually and had errors, Then copied and pasted the code into the onload event in the vba window and got the same errors
"The expression may not result in the name of a macro, the name of a user defined function or event procedure"
There may have been an error in evaluating the function, event or macro
I searched the web and found the suggestion to use the compile option in the VBA window which I did and got the error below
"Invalid Outside procedure!"
Code:
Private Sub Form_Load()
Dim PassWord As String
PassWord = InputBox(“Enter Administrator Password”)
If PassWord = “admin1234” Then
‘ Open Form
DoCmd.OpenForm “frmAddRecord”
DoCmd.GoToRecord , , acNewRec
Else
MsgBox (“You’re not authorized for Administrator access.”)
End If
End Sub
I do realise it's probably not terribly secure but it's really only to stop accidental changes rather than a determined attack
Would as usual appreciate any pointers
Thanks
Ian