BUG: Bookmark for Unbound DBGrid is Incorrect for the Last Row (176486)
The information in this article applies to:
- Microsoft Visual Basic Control Creation Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
This article was previously published under Q176486 SYMPTOMS
The Bookmark property of the DBGrid control can be used to save a reference
to the current row. By setting the Bookmark property, the current row can
be updated as well.
If the Bookmark property of an unbound DBGrid control is saved while the
last row is selected, setting the Bookmark property back to the saved value
will update the current row to be the first row, rather than the last.
RESOLUTION
As a workaround, use the RowBookmark method of the DBGrid control when
saving the Bookmark of the current row:
Private MyBookmark
Private Sub cmdSaveBookmark_Click()
MyBookmark = DBGrid1.RowBookmark(DBGrid1.Row)
End Sub
Also, the following error handling code will need to be included when
updating the current row:
Private Sub cmdRestoreBookmark_Click()
On Error GoTo err_handler
DBGrid1.Bookmark = MyBookmark
Exit Sub
err_handler:
Dim r
If Err.Number = 6149 Then
For r = 0 To DBGrid1.VisibleRows - 1
DBGrid1.Row = r
Next r
Resume
Else
Err.Raise Err.Number
End If
End Sub
The above error handling code is necessary because the bug associated with
the Bookmark property for the last row will also cause run-time error 6149.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. We are researching this
bug and will post new information here in the Microsoft Knowledge
Base as it becomes available.
Modification Type: | Major | Last Reviewed: | 12/10/2003 |
---|
Keywords: | kbbug KB176486 |
---|
|