Results 1 to 36 of 36

Thread: [RESOLVED] Help Plz

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Resolved [RESOLVED] Help Plz

    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:
    1. .Fields("uname") = txtUser.Text

    Can anyone help my whole code is below.

    VB Code:
    1. Public CN As New ADODB.Connection
    2. Public RS As New ADODB.Recordset
    3.  
    4.  
    5. Private Sub cmdClose_Click()
    6. CN.Close
    7. Unload Me
    8. End Sub
    9.  
    10. Private Sub cmdDelete_Click()
    11.     With RS
    12.         CN.Execute "DELETE * FROM users WHERE uname ='" & .Fields("uname") & "'"
    13.         .Requery ' update our datagrid
    14.     End With
    15. End Sub
    16.  
    17. Private Sub cmdNew_Click()
    18.     txtUser.Text = ""
    19.     txtPass.Text = ""
    20.     RS.AddNew
    21. End Sub
    22.  
    23. Private Sub cmdSave_Click()
    24.     With RS
    25.         If txtUser.Text <> "" And txtPass.Text <> "" Then
    26.         .Fields("uname") = txtUser.Text
    27.         .Fields("pass") = txtPass.Text
    28.         .Update
    29.     End If
    30.     End With
    31. End Sub
    32.  
    33. Private Sub Form_Load()
    34.  
    35.     CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
    36.     RS.CursorLocation = adUseClient
    37.     RS.Open "SELECT * FROM users ORDER BY uname ASC", CN, adOpenStatic, adLockOptimistic
    38.     Set DataGrid1.DataSource = RS
    39.  
    40.  
    41.  
    42.     DataGrid1.Columns(0).Caption = "Username"
    43.     DataGrid1.Columns(1).Caption = "Password"
    44.  
    45. End Sub
    Last edited by Jamie_Garland; Dec 1st, 2006 at 09:14 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width