Export (0) Print
Expand All

DoCmd.GoToRecord Method

Office 2007
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

NameRequired/OptionalData TypeDescription
ObjectTypeOptionalAcDataObjectTypeA AcDataObjectType constant that specifies the type of object that contains the record you want to make current.
ObjectNameOptionalVariantA string expression that's the valid name of an object of the type selected by the objecttype argument.
RecordOptionalAcRecordA AcRecord constant that specifies the record to make the current record. The default value is acNext.
OffsetOptionalVariantA 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

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.

Example

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

Visual Basic for Applications
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7


Community Additions

ADD
Show:
© 2014 Microsoft