Error 3159 Not a valid bookmark:

While working with MS Access VBA, recordset bookmark property with invalid string, then Error 3159 not valid bookmark will occur. Recordset bookmark property sets or returns a bookmark that uniquely identifies the current record in a Recordset object. For a Recordset object based entirely on Microsoft Access database engine tables, the value of the Bookmarkable property is true, and you can use the Bookmark property with that Recordset. Recordset bookmark property sets or returns a bookmark that uniquely identifies the current record in a Recordset object. Error 3159 is the most common error, occurred while working with recordsets. When user uses the bookmark property of recordset object to bookmark invalid string, then this error will prompted. The other cause of this error is when user bookmark a string that was not saved from previously reading a Bookmark property. This article reproduce the error behavior and to resolving this error 3159.

To reproduce error user need to create table, so that in VBA he will able to create recordset. After click on Form button an error 3159 will generated as shown in Fig 1.1.

MS Access VBA Error 3159 Not a valid bookmark Fig 1.1

Fig 1.1

Code to reproduce the error:

Option Compare Database
Private Sub Command0_Click()
Dim rst As Recordset
Dim str As String
'Error 3159 Not a valid bookmark.
Set rst = CurrentDb.OpenRecordset("Table1", dbOpenDynaset)
str = rst(0)
rst.Bookmark = str
End Sub

Resolution: Save the string that after reading a Bookmark property. So for next time it's available.

Use the valid string to accomplish the task.


DISCLAIMER

It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.