편집

다음을 통해 공유


DoCmd.GoToRecord method (Access)

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

Syntax

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

expression A variable that represents a DoCmd object.

Parameters

Name Required/Optional Data type Description
ObjectType Optional AcDataObjectType An AcDataObjectType constant that specifies the type of object that contains the record that 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 An 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.

Remarks

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.

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.

Example

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

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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.