A
Altemir
I have a form in an ADP project that allows the user to delete a
selected record. The problem is that I want the record selector to
return to the adjacent record after the deletion is made, but it won't
do that -- the cursor always jumps to the top of the recordset. How
can I use a bookmark to return the cursor to the place (more or less)
where the deleted record used to be?
Here's what I got now:
' Store current recordset and primary key value for current record
Set rst = Me.Recordset
iRecID = Me!RecID
' Bookmark record that is adjacent to record that is currently selected
' and will be deleted
With rst
If .BOF = True Then
.MoveNext
Else
.MovePrevious
End If
bm = .Bookmark
End With
DoCmd.RunSQL "DELETE FROM dbo.MyTable WHERE RecID = " & CStr(iRecID)
Set Me.Recordset = rst
Me.Refresh
' Return to adjacent record (this is what is not working)
Me.Bookmark = bm
selected record. The problem is that I want the record selector to
return to the adjacent record after the deletion is made, but it won't
do that -- the cursor always jumps to the top of the recordset. How
can I use a bookmark to return the cursor to the place (more or less)
where the deleted record used to be?
Here's what I got now:
' Store current recordset and primary key value for current record
Set rst = Me.Recordset
iRecID = Me!RecID
' Bookmark record that is adjacent to record that is currently selected
' and will be deleted
With rst
If .BOF = True Then
.MoveNext
Else
.MovePrevious
End If
bm = .Bookmark
End With
DoCmd.RunSQL "DELETE FROM dbo.MyTable WHERE RecID = " & CStr(iRecID)
Set Me.Recordset = rst
Me.Refresh
' Return to adjacent record (this is what is not working)
Me.Bookmark = bm