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:
Private Sub cmdDelete_Click() On Error GoTo Err: With tbAcademicYear '--------------------------------- 'Check if there is no record '--------------------------------- If .RecordCount < 1 Then MsgBox "No school year in the list.Please check it!", vbExclamation, "CSRS version 1": Exit Sub '--------------------------------- 'Confirm deletion of record '--------------------------------- Dim ans As Integer Dim pos As Integer ans = MsgBox("Are you sure you want to delete the selected record?", vbCritical + vbYesNo, "Confirm Record Delete") If ans = vbYes Then '----------------------------- 'Delete the record '----------------------------- pos = Val(LV1.SelectedItem) If .EOF = False Then .Delete adAffectCurrent .Requery Else MsgBox "huh" End If If .RecordCount > 0 Then .AbsolutePosition = pos If .EOF Then .MoveFirst '--------------------------------- 'Fill listview '--------------------------------- pos = .AbsolutePosition load_rec LV1.ListItems.Item(pos).EnsureVisible LV1.ListItems.Item(pos).Selected = True .AbsolutePosition = LV1.SelectedItem '--------------------------------- 'End-fill listview '--------------------------------- 'Else ' LV1.ListItems.Clear End If MsgBox "Record has been successfully deleted.", vbInformation, "Confirm" End If ans = 0 pos = 0 Me.MousePointer = vbDefault End With Exit Sub Err: MsgBox Err.Description, vbCritical, "Academic Year" End Sub Private Sub Form_Load() tbAcademicYear.CursorLocation = adUseClient tbAcademicYear.Open "Select * from tbacademicyear", cn, adOpenDynamic, adLockOptimistic CallFields End Sub




Reply With Quote