Bookmark attribute referenced by an object

Source: Internet
Author: User

Bookmark indicates the meaning of a bookmark.

Return the tag that uniquely identifies the current record in the recordset object, or set the current record of the recordset object to the record identified by a valid bookmarks. The return value belongs to the variant type.

Description

The bookmark attribute stores the location of the current record and returns it to the record at any time. Bookmarks can only be used in recordset objects that support bookmarks.

Each record of A recordset object has a unique bookmarks. Whether to save the current bookmarks or apply the principle of switching in VB. Borrow a third party. A = B, B = C, C = A to return to the original bookmarks.

The following is a common example:

Private sub deletecommand_click ()
Mybookmark = MRC. bookmark
Str2 $ = msgbox ("Do you want to delete the current record? ", Vbokcancel," delete current record ")
If str2 $ = vbok then
MRC. movenext
If MRC. EOF then
MRC. movefirst
Mybookmark = MRC. bookmark' to record a location with a bookmark
MRC. movelast
MRC. Delete
MRC. Bookmark = mybookmark' is equivalent to a = B, B = C, C = A mentioned above.
Call viewdata
Else
Mybookmark = MRC. bookmark
MRC. moveprevious
MRC. Delete
MRC. Bookmark = mybookmark
Call viewdata
End if
Else
MRC. Bookmark = mybookmark
Call viewdata
End if
End sub

This example indicates that when deleting a record, we need to make a judgment. You may wonder why there is MRC. movenext. There are two extreme cases. First, explain the application of the pointer in the record.


There are usually two extreme pointers in the object record set: Bof and EOF

When the Pointer Points to the top of the first record, that is, where no record exists, the return value of the BOF attribute is true, and the reverse value is false.

When the Pointer Points to the bottom part of the last record, the return value of the EOF attribute is true, and the reverse value is false.

Therefore, when deleting a file, you need to consider the following two situations:

1. Move down to make a judgment. If the EOF attribute is true, the last record is deleted. At this time, the pointer is moved to the first record and the tag is mounted. Because the last record is to be deleted, after moving to the last record and deleting it, return the tag.

2. Move down to make a judgment. If the EOF attribute is false, it indicates that the last record is not deleted. At this time, because we move the pointer down, we need to delete the previous record, let the pointer return the previous one again, delete it again, and then return the tag again.

The above is what we should pay attention to when deleting records.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.