Can anyone help me with this minor problem please.
I have deleted all my accounts from my database ok but when i type in a new username and password and click on save i get an error saying the following.
Run-time error '3021':
Either BOF or EOF is True, or the current record has been deleted Requested operation requires a current record.
and it then highlights the following code.
VB Code:
.Fields("uname") = txtUser.Text
Can anyone help my whole code is below.
VB Code:
Public CN As New ADODB.Connection Public RS As New ADODB.Recordset Private Sub cmdClose_Click() CN.Close Unload Me End Sub Private Sub cmdDelete_Click() With RS CN.Execute "DELETE * FROM users WHERE uname ='" & .Fields("uname") & "'" .Requery ' update our datagrid End With End Sub Private Sub cmdNew_Click() txtUser.Text = "" txtPass.Text = "" RS.AddNew End Sub Private Sub cmdSave_Click() With RS If txtUser.Text <> "" And txtPass.Text <> "" Then .Fields("uname") = txtUser.Text .Fields("pass") = txtPass.Text .Update End If End With End Sub Private Sub Form_Load() CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb" RS.CursorLocation = adUseClient RS.Open "SELECT * FROM users ORDER BY uname ASC", CN, adOpenStatic, adLockOptimistic Set DataGrid1.DataSource = RS DataGrid1.Columns(0).Caption = "Username" DataGrid1.Columns(1).Caption = "Password" End Sub




Reply With Quote