GoToRecord Method
The GoToRecord method carries out the GoToRecord action in Visual Basic.
expression.GoToRecord(ObjectType, ObjectName, Record, Offset)
expression Required. An expression that returns one of the objects in the Applies To list.
ObjectType Optional AcDataObjectType.
AcDataObjectType can be one of these AcDataObjectType constants. |
acActiveDataObject default |
acDataForm |
acDataFunction |
acDataQuery |
acDataServerView |
acDataStoredProcedure |
acDataTable |
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.
AcRecord can be one of these AcRecord constants. |
acFirst |
acGoTo |
acLast |
acNewRec |
acNext default |
acPrevious
If you leave this argument blank, the default constant (acNext) is assumed. |
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
For more information on how the action and its arguments work, see the action topic.
If you leave the objecttype and objectname arguments blank (the default constant, acActiveDataObject, is assumed for objecttype), the active object is assumed.
You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave one or more trailing arguments blank, don't use a comma following the last argument you specify.
Example
The following example uses the GoToRecord method to make the seventh record in the form Employees current:
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7