469,646 Members | 1,647 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Error 'No Current Record' when trying to delete

52
i'm trying to create a reminder form, when i add a new reminder its ok but when i try to delete a reminder then i get No Current Record problem.

Form Load
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Dim s() As String
  3.     Dim ListTime As String
  4.     Dim ListDate As String
  5.     Dim i As Integer
  6.     Set dbReminder = OpenDatabase(App.Path & "\Password.mdb")
  7.     Set rsReminder = dbReminder.OpenRecordset("Reminder", dbOpenDynaset)
  8.  
  9.     If Not rsReminder.EOF Then rsReminder.MoveFirst
  10.  
  11.     Do While Not rsReminder.EOF
  12.         lstReminder.AddItem rsReminder!Rno & "." & " " & rsReminder!Name & vbTab & vbTab & rsReminder!Date & vbTab & rsReminder!Time
  13.         lstReminder.ItemData(lstReminder.NewIndex) = rsReminder!Rno
  14.         rsReminder.MoveNext
  15.     Loop
  16.     For i = 0 To lstReminder.ListCount - 1
  17.         s = Split(lstReminder.List(i), vbTab)
  18.         ListTime = Mid(s(UBound(s)), 1, Len(s(UBound(s))) - 3)
  19.         ListDate = s(UBound(s) - 1)
  20.         If ListTime = Mid(Time, 1, Len(Time) - 3) And ListDate = Date Then
  21.             MsgBox rsReminder!Name & "ghghgh"
  22.         End If
  23.     Next
  24. End Sub
  25.  
My List Box
Expand|Select|Wrap|Line Numbers
  1. Private Sub List1_Click()
  2.     rsReminder.FindFirst "Rno=" & (lstReminder.ItemData(lstReminder.ListIndex))
  3.     rsReminder!Rno = frmReminder.txtno.Text
  4.     rsReminder!Name = frmReminder.txtName.Text
  5.     rsReminder!Date = frmReminder.txtDate.Text
  6.     rsReminder!Time = frmReminder.txtTime.Text
  7.     rsReminder!Comments = frmReminder.txtComment.Text
  8. End Sub
  9.  
My Delete Button
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelete_Click()
  2.     Const strDelete As String = "Are you sure you want to delete this record?"
  3.     Dim response As Integer
  4.  
  5.     response = MsgBox(strDelete, vbYesNo + vbQuestion + vbDefaultButton2, "Delete record")
  6.     If response = vbYes Then
  7.       rsReminder.Delete
  8.       lstReminder.RemoveItem lstReminder.ListIndex
  9.      ' MsgBox txtFname & " " & txtSname & " has been deleted from the record", vbInformation + vbOKOnly, "Record Deleted"
  10.      ' Call cmdClear_Click
  11.     End If
  12. End Sub
  13.  
I get the error on this line " rsReminder.Delete" on the delete button. Does anyone know what is the poblem.
I THANK U ANY ANSWERS
Mar 13 '08 #1
1 1680
Killer42
8,435 Expert 8TB
I think the problem is in your listbox click routine. You're not selecting a record, but simply stuffing values into the recordset as though you were about to store a new record.

I'd say that routine probably should be doing a FindFirst or similar, to position the recordset to the selected record.
Mar 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Steve | last post: by
5 posts views Thread by prakashwadhwani | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.