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:
- When you set a Recordset.bookmark property (DAO) with an invalid string.
- When your Access database is corrupted.
- When you try to bookmark a string that was not saved earlier.
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:
- Identify the path of your Microsoft Access. For this, you can search your Access program from Windows Explorer.
- Open the Command Prompt window by typing cmd in the Run utility.
- Click OK.
- The cmd.exe window is displayed.
- Enter the following Decompile command.
C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE /decompile
- Now, open the MS Access database.
- Click Create > Module.
- Click File and then Save.
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:
- Open Microsoft Access.
- Go to File > Info > Compact & Repair Database.
- Select the corrupt Access database file and then click OK.
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.
Was this article helpful?