Bookmark Property

Applies To

Form.

Description

You can use the Bookmark property with forms to set a bookmark that uniquely identifies a particular record in the form’s underlying table, query, or SQL statement.

Setting

The Bookmark property contains a string expression created by Microsoft Access.

You can access this property using Visual Basic or a macro.

Note You get or set the form’s Bookmark property separately from the underlying table or query data access Bookmark property.

Remarks

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.

Note Bookmarks are not saved with the records they represent. They are re-created by Microsoft Access each time a bound form is opened.

There is no limit to the number of bookmarks you can save if each is saved with a unique string variable.

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 with a string variable that identifies this record.

You can use bookmarks in any form that is based entirely on Microsoft Access tables. However, other database products may not support bookmarks. For example, you can’t use bookmarks in a form based on a linked table that has no primary index.

Requerying a form invalidates any bookmarks set on records in the form. However, clicking Refresh on the Records menu doesn’t affect bookmarks.

Since Microsoft Access creates a unique bookmark for each record in a form’s recordset when a form is opened, a form’s bookmark will not work on another recordset, even when the two recordsets are based on the same table, query or SQL statement. For example, suppose you open a form bound to the Customers table. If you then open the Customers table using Visual Basic and use the Seek method to locate a specific record in the table, you can’t set the form’s Bookmark property to the current table record. To perform this kind of operation you use the form’s RecordsetClone property.

A trappable error occurs if you save the Bookmark property with a string variable and then try to return to that record after the record has been deleted.

The value of the Bookmark property isn’t the same as a record number.

See Also

Bookmark Property (Microsoft Office 95 Data Access Reference), RecordsetClone Property.

Example

The following example determines the Bookmark property for the current record in the Customers form.


Dim strLocation As String= Forms![Customers].Bookmark