Hello, I've learned how to created a login form through a youtube tutorial for my database. It has instructed me to create a button that has the following event procedure (using code builder).
Username.SetFocus
If Username = "staff1" And Password = "staff1" Then
MsgBox "Access Granted", vbInformation, "CD Shop"
MsgBox "Welcome", vbInformation, "CD Shop"
DoCmd.Close
DoCmd.OpenForm "F_Switchboard_MainMenu"
ElseIf Username = "staff2" and Password = "staff2" Then
MsgBox "Access Granted", vbinformation, "CD Shop"
MsgBox "Welcome", vbinformation, "CD Shop"
DoCmd.Close
DoCmd.OPenForm "F_Switchboard_MainMenu"
ElseIf Username = "manager1" and Password = "manager1" Then
MsgBox "Welcome, Manager", vbinformation, "Manager Area"
MsgBox "Please Exercise Caution When Altering Back End", vbinformation, "Manager Area"
DoCmd.Close
DoCmd.OPenForm "F_Switchboard_MainMenu"
Else
MsgBox "Please re-enter your Username and Password."
End If
The button runs perfectly.
However, when i tried to save it, a message box appears.
Run-time error '3709':
The search key was not found in any record.
The next time I opened the database and tried to log in, the button no longer works anymore.
If you dont mind, can you kindly please explain to me why does this happen and what can i do to solve this error?
I'm just a beginner in using Ms Access and Visual Basic, so much explanation is needed.
Please help me. Thank you.