How to Fix MS Access Error 3159 – “Not A Valid Bookmark”?

Summary: MS Access users may encounter the "Not a valid bookmark” error when using the record set in VBA projects. This blog will discuss the reasons behind “MS Access error 3159: Not a valid bookmark” and the solutions to resolve it. You’ll also find about an Access database repair tool that can help fix the error if it occurs due to corrupted records in the database.

The MS Access error ?Not a valid bookmark? usually occurs when you set the bookmark property of a record set with an invalid string. The bookmark property is used to access/fetch records in database tables.

The error appears like this:

There are various reasons that may lead to the ?Not a valid bookmark? error in Microsoft Access, such as:

 Methods to Fix MS Access Error 3159: Not a Valid Bookmark

You can try the following solutions to resolve the MS Access error 3159.

Method 1: Reproduce the Error

If you get the “Not a valid bookmark? error due to invalid string in the bookmark property, then you can reproduce the error to find and correct the string. For this, use the below code in the module:

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("Orders", dbOpenDynaset)
str = rst(0)
rst.Bookmark = str
End Sub

On the error message window, click the Debug option and then,

  • Use the correct string.
  • Update the string and save it for later.

Method 2: Use the Decompile Command

When VBA code throws an error or behaves oddly, you can use the Decompile command. This command is used to fix VBA-related errors. To use the Decompile command, follow these steps:

C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE /decompile

Method 3: Repair the Database

Sometimes, the MS Access error 3159 can occur when the MS database is corrupted. You can use the built-in utility ? Compact and Repair – to repair the damaged or corrupted database. To run this tool, follow these steps:

Now, check if the issue is resolved. If the error persists or the ?Compact and Repair utility doesn?t work?, then you can use a professional Access repair tool, like Stellar Repair for Access. This tool is recommended by certified database experts to repair corrupt Access database files (.ACCDB and .MDB). It helps you recover all the database objects, including queries, reports, tables, reports, etc. The tool is compatible with Office 365, Access 2019, 2016, 2013, and lower versions.

Closure

The MS Access error 3159 occurs when working with recordsets in VBA code. It usually occurs when you try to use an invalid string while setting the Recordset.Bookmark property. You can fix the issue by reproducing the error and then correcting the string value. If the database is corrupted, you can use the Compact and Repair tool in MS Access. If this utility fails, you can try Stellar Repair for Access to repair the corrupt Access database files. It can fix severely corrupted database files and recover all the data without changing its original structure. It is an advanced tool that can help you fix MS error 3159 or any other corruption-related error.

Related Post