Hi, actually I'm creating a database for some coursework at school. It's basically about a booking system and how I book hardware in and out of the school for students who need the hardware. I've tried to create a login screen, so that teachers can log in and out the system. I've got one table that is involved in this code, which is the 'tblTechnicianF ile'. That's the table that contains the technician's ID and the password as well. The following links are print screens of my tblTechnicianFi le and my actual form, which is my login screen.
http://i209.photobucke t.com/albums/bb68/ud1992/ms%20access%20p rob/Untitled-2.png
http://i209.photobucke t.com/albums/bb68/ud1992/ms%20access%20p rob/Untitled-4.png
The problem is that it is supposed to send me to another screen when the password is right, but it keeps giving me the "run-time error..." screen whether I put in the right password or not.
This is the all the codes that I have got entered, something must be wrong with it, but I cannot spot it. Help.
Option Compare Database
Private Sub cboEmployee_Aft erUpdate()
Me.txtPassword. SetFocus
End Sub
Private Sub cmdLogin_Click( )
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEm ployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee. SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPa ssword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword. SetFocus
Exit Sub
End If
'Check value of password in login to see if this
'matches value chosen in combo box
If Me.txtPassword. Value = DLookup("Passwo rd", "tblTechnicianF ile", _
"[Technician ID]=" & Me.cboEmployee. Value) Then
lngMyEmpID = Me.cboEmployee. Value
'Close logon form and open splash screen
DoCmd.Close acForm, "login screen", acSaveNo
DoCmd.OpenForm "Switchboar d"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword. SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempt s = intLogonAttempt s + 1
If intLogonAttempt s > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Qui t
End If
End Sub
---------------------------------------------------------------------------------------------------------------
Additional Details
if anyone wants to contact me to get more details about this problem or anything like that, my msn is: uddeshd@yahoo.c o.uk
http://i209.photobucke t.com/albums/bb68/ud1992/ms%20access%20p rob/Untitled-2.png
http://i209.photobucke t.com/albums/bb68/ud1992/ms%20access%20p rob/Untitled-4.png
The problem is that it is supposed to send me to another screen when the password is right, but it keeps giving me the "run-time error..." screen whether I put in the right password or not.
This is the all the codes that I have got entered, something must be wrong with it, but I cannot spot it. Help.
Option Compare Database
Private Sub cboEmployee_Aft erUpdate()
Me.txtPassword. SetFocus
End Sub
Private Sub cmdLogin_Click( )
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEm ployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee. SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPa ssword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword. SetFocus
Exit Sub
End If
'Check value of password in login to see if this
'matches value chosen in combo box
If Me.txtPassword. Value = DLookup("Passwo rd", "tblTechnicianF ile", _
"[Technician ID]=" & Me.cboEmployee. Value) Then
lngMyEmpID = Me.cboEmployee. Value
'Close logon form and open splash screen
DoCmd.Close acForm, "login screen", acSaveNo
DoCmd.OpenForm "Switchboar d"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword. SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempt s = intLogonAttempt s + 1
If intLogonAttempt s > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Qui t
End If
End Sub
---------------------------------------------------------------------------------------------------------------
Additional Details
if anyone wants to contact me to get more details about this problem or anything like that, my msn is: uddeshd@yahoo.c o.uk
Comment