Bookmark issue when on 1st record--Error 3159

lmcc007

Registered User.
Local time
Yesterday, 19:43
Joined
Nov 10, 2007
Messages
635
When I am on the first record on the list and I open the form to delete that record, upon closing the form I get Error Number: 3159--not a valid bookmark. Below is the code I am using:

Code:
     Dim bkMark As String

     If CurrentProject.AllForms("frmViewEventHistoryList").IsLoaded Then
        bkMark = Forms!frmViewEventHistoryList.Bookmark
        Forms!frmViewEventHistoryList.Requery
        Forms!frmViewEventHistoryList.Bookmark = bkMark
    End If
Is there a way I can tell it to go to next record if I delete the record I selected?
 
It appears to me that you may be attempting to return the form to the record just deleted. I have not had much experience with book marks, but if you are attempting to delete a record try the following. Prior to actually deleting the record go to either the next or prior record and save that bookmark value to a variable. Upon deleting the record use the bookmarked variable to return to what was the prior or next record.

Of course you will need to test whether a prior or next record exist before implementing.
 
It appears to me that you may be attempting to return the form to the record just deleted. I have not had much experience with book marks, but if you are attempting to delete a record try the following. Prior to actually deleting the record go to either the next or prior record and save that bookmark value to a variable. Upon deleting the record use the bookmarked variable to return to what was the prior or next record.

Of course you will need to test whether a prior or next record exist before implementing.

Huh? Too complicated--need something simple.
 
That's two of us! Below is guidance from Access Help.
When a bound form is opened in Form view , each record is assigned a unique bookmark. In Visual Basic, you can save the bookmark for the current record by assigning the value of the form's Bookmark property to a string variable. To return to a saved record after moving to a different record, set the form's Bookmark property to the value of the saved string variable. You can use the StrComp function to compare a Variant or string variable to a bookmark, or when comparing a bookmark against a bookmark. The third argument for the StrComp function must be set to a value of zero. (Emphasis added)
The Bookmark property is only available for the form's current record. To save a bookmark for a record other than the current record, move to the desired record and assign the value of the Bookmark property to a string variable that identifies this record.

Requerying a form invalidates any bookmarks set on records in the form. However, clicking Refresh on the Records menu doesn't affect bookmarks. (Emphasis added)
Note that requerying invalidates any bookmarks. You have the following: "Forms!frmViewEventHistoryList.Requery"

An error occurs if you set the Bookmark property to a string variable and then try to return to that record after the record has been deleted.

See if the Access Help guidance above helps.
 

Users who are viewing this thread

Back
Top Bottom