|
-
Feb 10th, 2007, 02:30 AM
#1
Thread Starter
Lively Member
.eof or .bof is closed problem again
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
-
Feb 10th, 2007, 03:18 AM
#2
Frenzied Member
Re: .eof or .bof is closed problem again
try using adOpenStatic .... and/or adUseServer
-
Feb 10th, 2007, 05:56 AM
#3
Re: .eof or .bof is closed problem again
Are you sure the record you are trying to delete exists?
-
Feb 12th, 2007, 04:22 AM
#4
Re: .eof or .bof is closed problem again
does recordcount return valid count when you are using a dynamic cursor? or just -1
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|