Hi people, its me the noob again haha .. something's gone wrong with my login form. compile error .. rstUsers.Index = "UserID" .. the index seems to have some kind of problem. anyone can help?



Private Sub btnCancel_Click()

End

End Sub

Private Sub Form_Load()

btnLogin.Enabled = False
gintKeypresscount = 0

End Sub

Private Sub txtLoginID_GotFocus()

gintKeypresscount = 0

End Sub

Private Sub txtLoginID_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

KeyAscii = 0

gintKeypresscount = 1
SearchEmployee

End If

End Sub

Private Sub txtLoginID_LostFocus()

If gintKeypresscount = 0 And txtLoginID.Text <> "" Then
gintKeypresscount = 1
SearchEmployee
End If

End Sub

Private Sub txtPassword_GotFocus()

If txtLoginID.Text = "" Then
txtLoginID.SetFocus
End If

gintKeypresscount = 0

End Sub

Private Sub txtPassword_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
If gintKeypresscount = 0 And txtPassword.Text <> "" Then
KeyAscii = 0
gintKeypresscount = 1
SearchPassword
End If
End If

If txtPassword <> "" Then
btnLogin.Enabled = True
End If

End Sub

Sub SearchEmployee()

'establish connection to database
Dim dcnRefund As New ADODB.Connection
dcnRefund.CursorLocation = adUseClient
dcnRefund.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source = D:\Alvin Tan\My Documents\Refund\Refund.mdb;"

'create recordset
Dim rstUsers As ADODB.Recordset
Set rstUsers = New ADODB.Recordset
rstUsers.CursorType = adOpenKeyset
rstUsers.LockType = adLockOptimistic
rstUsers.Open "tblRefundUsers", dcnRefund, adOpenStatic, adLockOptimistic

rstUsers.Index = "UserID"
rstUsers.Seek "=", txtLoginID.Text

If rstUsers.NoMatch Then
MsgBox "Sorry, User not found!", vbExclamation
gintKeypresscount = 0
txtLoginID.Text = ""
txtLoginID.SetFocus
Else
txtPassword.SetFocus
btnLogin.Enabled = True
End If

rstUsers.Close

dcnRefund.Close

End Sub

Sub SearchPassword()

'establish connection to database
Dim dcnRefund As New ADODB.Connection
dcnRefund.CursorLocation = adUseClient
dcnRefund.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source = D:\Alvin Tan\My Documents\Refund\Refund.mdb;"

'create recordset
Dim rstUsers2 As ADODB.Recordset
Set rstUsers2 = New ADODB.Recordset
rstUsers2.CursorType = adOpenKeyset
rstUsers2.LockType = adLockOptimistic
rstUsers2.Open "tblRefundUsers", dcnRefund, adOpenStatic, adLockOptimistic

If txtLoginID.Text = "" Then
MsgBox "Please enter User Login ID", vbExclamation
gintKeypresscount = 0
txtLoginID.Text = ""
txtLoginID.SetFocus
Exit Sub
End If

rstUsers2.Index = "UserID"
rstUsers2.Seek "=", txtLoginID.Text

If txtPassword.Text = "" And gintKeypresscount = 1 Then
MsgBox "Please enter password", vbExclamation
gintKeypresscount = 0
txtPassword.SetFocus
Else
If rstUsers2("UserPwd") = txtPassword.Text Then
gintLoginID = UCase(txtLoginID.Text)
Unload Me
frmMainMenu.Show
Else
MsgBox "Wrong Password!", vbExclamation
gintKeypresscount = 0
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If

rstUsers2.Close
dcnRefund.Close

End Sub