Hi could someone help me solve the code for my Login form? I keep getting the error: Either BOF or EOF is True, or the current record has been deleted
Thanks in advance
Public conn As String
Public rs As New ADODB.Recordset
Public Function CN(str As String, loc As CursorLocationEnum, ConStr As String) As Recordset
Set CN = New ADODB.Recordset
CN.CursorLocation = adUseClient
CN.CursorType = adOpenKeyset
CN.LockType = adLockOptimistic
CN.Open str, ConStr, , , adCmdText
End Function
Sub Main()
conn = "Provider = Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\Database\dbase.mdb;"
frmLogin.Show
End Sub
Private Sub cmdOK_Click()
Dim uname, pword As String
uname = "Username"
pword = "Password"
Set rs = CN("select * from user_tbl where username = ' " & Trim(txtUserName.Text) & " ' ", adUseClient, conn)
If txtUserName.Text = rs!Username And txtPassword.Text = rs!Password Then
Form1.Show
ElseIf txtUserName.Text <> rs!Username And txtPassword.Text <> rs!Password Then
MsgBox "Incorrect User name and Password"
ElseIf txtPassword.Text <> rs!Password Then
MsgBox "Incorrect Password"
ElseIf txtUserName.Text <> rs!Username Then
MsgBox "Incorrect User Name"
Exit Sub
End If
End Sub
Thanks in advance
Public conn As String
Public rs As New ADODB.Recordset
Public Function CN(str As String, loc As CursorLocationEnum, ConStr As String) As Recordset
Set CN = New ADODB.Recordset
CN.CursorLocation = adUseClient
CN.CursorType = adOpenKeyset
CN.LockType = adLockOptimistic
CN.Open str, ConStr, , , adCmdText
End Function
Sub Main()
conn = "Provider = Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\Database\dbase.mdb;"
frmLogin.Show
End Sub
Private Sub cmdOK_Click()
Dim uname, pword As String
uname = "Username"
pword = "Password"
Set rs = CN("select * from user_tbl where username = ' " & Trim(txtUserName.Text) & " ' ", adUseClient, conn)
If txtUserName.Text = rs!Username And txtPassword.Text = rs!Password Then
Form1.Show
ElseIf txtUserName.Text <> rs!Username And txtPassword.Text <> rs!Password Then
MsgBox "Incorrect User name and Password"
ElseIf txtPassword.Text <> rs!Password Then
MsgBox "Incorrect Password"
ElseIf txtUserName.Text <> rs!Username Then
MsgBox "Incorrect User Name"
Exit Sub
End If
End Sub