GoToRecord Method

Applies To

DoCmd Object.

Description

The GoToRecord method carries out the GoToRecord action in Visual Basic. For more information on how the action and its arguments work, see the GoToRecord action topic.

Syntax

DoCmd.GoToRecord [objecttype, objectname] [, record] [, offset]

The GoToRecord method uses the following arguments.

Argument

Description

objecttype

One of the following intrinsic constants:

acTable
acQuery
acForm

objectname

A string expression that is the valid name of an object of the type selected with the objecttype argument.

record

One of the following intrinsic constants:

acPrevious
acNext
acFirst
acLast
acGoTo
acNewRec

If you leave this argument blank, the default (acNext) is assumed.


Argument

Description

offset

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

If you leave the objecttype and objectname arguments blank, 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.

See Also

DoCmd Object, GoToControl Method, GoToPage Method (DoCmd Object), GoToRecord Action, SelectObject Method.

Example

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


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