DoCmd.GoToRecord Method (Access)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

The GoToRecord method carries out the GoToRecord action in Visual Basic.

expression .GoToRecord(ObjectType, ObjectName, Record, Offset)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

ObjectType

Optional

AcDataObjectType

A AcDataObjectType constant that specifies the type of object that contains the record you want to make current.

ObjectName

Optional

Variant

A string expression that's the valid name of an object of the type selected by the objecttype argument.

Record

Optional

AcRecord

A AcRecord constant that specifies the record to make the current record. The default value is acNext.

Offset

Optional

Variant

A numeric expression that represents the number of records to move forward or backward if you specify acNext or acPrevious for the record argument, or the record to move to if you specify acGoTo for the record argument. The expression must result in a valid record number.

You can use the GoToRecord method to make the specified record the current record in an open table, form, or query result set.

If you leave the objecttype and objectname arguments blank (the default constant, acActiveDataObject, is assumed for objecttype), the active object is assumed.

You can use the GoToRecord method to make a record on a hidden form the current record if you specify the hidden form in the objecttype and objectname arguments.

The following example uses the GoToRecord method to make the seventh record in the form Employees current:

DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7

Concepts

Other resources

Show:
© 2016 Microsoft