This is a process of deleting data in the database in VB. After clicking the buttonProgramThe first sentence is to save the location of the record you want to delete as a bookmark to the variable mybookmark. Then, if you choose to delete the record, first execute the first sentence under the IF statement.
MRC. movenext
That is to point the current record to the next record. If this "Next" record is already the next of the last record, it is the place where the null record is located (if MRC. EOF), then point the current record to the first record, because the current record cannot be blank (if you want to explain it in detail, I have already discussed it in the previous blog, this is an understanding of EOF and BOF), and then save the current record bookmarks after movernext in the mybookmark variable to overwrite the original location, then, move the current location to the data you want to delete and execute the delete statement.
MRC. movelast
MRC. Delete
This completes the deletion of the specified record. The next step is to display the next record of the record you want to delete before you delete it, because you have saved the record to mybookmark before, so you just need to assign the value back.
MRC. Bookmark = mybookmark
Then, use the custom viewdata () function to display it.
In the first else, movenext does not point to an empty zone. First, save the bookmarks of the movenext record (the next record of the record to be deleted) in mybookmark, and then
Moveprevious
Return to the record you want to delete and execute the DELETE command.
MRC. Delete
Then, the previous record is assigned to the bookmarks as the current record.
MRC. Bookmark = mybookmark
Then display the current record
Call viewdata
Not to mention the last Else.