can anyone help me with this...im trying to delete the record but the error is .eof or .bof is clsed or have been deleted. what will i do...



VB Code:
  1. Private Sub cmdDelete_Click()
  2. On Error GoTo Err:
  3. With tbAcademicYear
  4.     '---------------------------------
  5.     'Check if there is no record
  6.     '---------------------------------
  7.    If .RecordCount < 1 Then MsgBox "No school year in the list.Please check it!", vbExclamation, "CSRS version 1": Exit Sub
  8.     '---------------------------------
  9.     'Confirm deletion of record
  10.     '---------------------------------
  11.     Dim ans As Integer
  12.     Dim pos As Integer
  13.     ans = MsgBox("Are you sure you want to delete the selected record?", vbCritical + vbYesNo, "Confirm Record Delete")
  14.     If ans = vbYes Then
  15.         '-----------------------------
  16.         'Delete the record
  17.         '-----------------------------
  18.         pos = Val(LV1.SelectedItem)
  19.              If .EOF = False Then
  20.                 .Delete adAffectCurrent
  21.                 .Requery
  22.             Else
  23.                 MsgBox "huh"
  24.              End If
  25.  
  26.         If .RecordCount > 0 Then
  27.             .AbsolutePosition = pos
  28.             If .EOF Then .MoveFirst
  29.             '---------------------------------
  30.             'Fill listview
  31.             '---------------------------------
  32.             pos = .AbsolutePosition
  33.             load_rec
  34.             LV1.ListItems.Item(pos).EnsureVisible
  35.             LV1.ListItems.Item(pos).Selected = True
  36.             .AbsolutePosition = LV1.SelectedItem
  37.             '---------------------------------
  38.             'End-fill listview
  39.             '---------------------------------
  40.         'Else
  41.            ' LV1.ListItems.Clear
  42.         End If
  43.                 MsgBox "Record has been successfully deleted.", vbInformation, "Confirm"
  44.     End If
  45.     ans = 0
  46.     pos = 0
  47.     Me.MousePointer = vbDefault
  48. End With
  49. Exit Sub
  50. Err:
  51.     MsgBox Err.Description, vbCritical, "Academic Year"
  52.  
  53. End Sub
  54.  
  55.  
  56. Private Sub Form_Load()
  57. tbAcademicYear.CursorLocation = adUseClient
  58. tbAcademicYear.Open "Select * from tbacademicyear", cn, adOpenDynamic, adLockOptimistic
  59.  
  60. CallFields
  61. End Sub