Basic Login - Help Needed

Carmichael_NZ

New member
Local time
Today, 18:28
Joined
May 6, 2013
Messages
4
Can someone please help me, I am having problems getting the following code to work with access 2010:

Option Compare Database
Private Sub Login_Click()
Username.SetFocus
If Username = "marsdenj" And Password = "a" Then
MsgBox "Welcome", vbInformation, "VidShop | Staff Only"
DoCmd.Close
DoCmd.OpenForm "Staff_Area"
ElseIf Username = "westene" And Password = "b" Then
MsgBox "Welcome", vbInformation, "VidShop | Staff Only"
DoCmd.Close
DoCmd.OpenForm "Staff_Area"
ElseIf Username = "mathewsj" And Password = "c" Then
MsgBox "Welcome", vbInformation, "VidShop | Staff Only"
DoCmd.Close
DoCmd.OpenForm "Staff_Area"
ElseIf Username = "moranp" And Password = "d" Then
MsgBox "Welcome", vbInformation, "VidShop | Manager Area"
DoCmd.Close
DoCmd.OpenForm "Manager_Area"
ElseIf Username = "admin" And Password = "admin" Then
MsgBox "Welcome", vbInformation, "VidShop | Manager Area"
DoCmd.Close
DoCmd.OpenForm "Manager_Area"
Else
MsgBox "Please re-enter your Username and Password", vbInformation, "Incorrect Username or Password."
End If
End Sub

Thanks
 
I am having problems getting the following code to work with access 2010:
What are those problems? Does the code not run? do you get any error messages?
 
below is just the basics

Thanks
 

Attachments

It has the correct file extension but it is still not in A2003 format.
 
You are referencing the label in your code, you should reference your textbox.
In your case: Username should be me.text1
Password should be me.text3
Also Username.SetFocus is not required and not possible, you can't set focus to a label.
 

Users who are viewing this thread

Back
Top Bottom