John Reynolds
October 18th, 2001, 08:14 AM
Using a data environment (MS Jet 4.0 DB Provider). Have set up commands for each of the 4 tables (not using SQL statements). In frmMain, have DataGrid control with source of deTransfers & member of Location (1 of the tables = command).
The control includes all rows (fields) of the Location table, as it should. Have written procedures to add, edit, & delete a row. Using code below, when user deletes a row, gets error . . . "Row handle referred to a deleted row or a row marked for deletion." HOWEVER, when I step through (F8), execution does not stop! Works fine. Row gets deleted from record set & DB! When I do not step through & execution halts & I press Debug, execution is on the line following .Delete.
What is going on? Thanks for any suggs.
John
private Sub mnuDeleteLocation_Click()
on error GoTo HandleError
With deTransfers.rsLocation
.Delete 'Delete the current record
.MoveNext 'EXECUTION stops here (after .Delete) when NOT debugging - Move to the following record
If .EOF then 'If last record deleted
.MovePrevious
If .BOF then 'If BOF and EOF true, no records remain
MsgBox "The recordset is empty.", vbInformation, "No records"
End If
else: .MoveFirst
End If
End With
Exit Sub
HandleError:
MsgBox "Unable to carry out requested action.", vbInformation, "Video Bonanza"
on error GoTo 0
End Sub
The control includes all rows (fields) of the Location table, as it should. Have written procedures to add, edit, & delete a row. Using code below, when user deletes a row, gets error . . . "Row handle referred to a deleted row or a row marked for deletion." HOWEVER, when I step through (F8), execution does not stop! Works fine. Row gets deleted from record set & DB! When I do not step through & execution halts & I press Debug, execution is on the line following .Delete.
What is going on? Thanks for any suggs.
John
private Sub mnuDeleteLocation_Click()
on error GoTo HandleError
With deTransfers.rsLocation
.Delete 'Delete the current record
.MoveNext 'EXECUTION stops here (after .Delete) when NOT debugging - Move to the following record
If .EOF then 'If last record deleted
.MovePrevious
If .BOF then 'If BOF and EOF true, no records remain
MsgBox "The recordset is empty.", vbInformation, "No records"
End If
else: .MoveFirst
End If
End With
Exit Sub
HandleError:
MsgBox "Unable to carry out requested action.", vbInformation, "Video Bonanza"
on error GoTo 0
End Sub