GoToRecord Action

Description

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

Setting

The GoToRecord action uses the following arguments.

Action argument

Description

Object Type

The type of object that contains the record you want to make current. You can click Table, Query, or Form in the Object Type box in the Action Arguments section of the Macro window. Leave this box blank to select the active object.

Object Name

The name of the object that contains the record you want to make the current record. The Object Name box shows all objects in the current database of the type selected with the Object Type argument. If you left the Object Type box blank, leave this box blank also.

Record

The record to make the current record. Click Previous, Next, First, Last, Go To, or New from the Record box. The default is Next.

Offset

An integer or expression, which is preceded by an equal sign (=) that evaluates to an integer. This argument specifies the record to make the current record. You can use Offset in two ways:


  • When the Record argument is Next or Previous, Microsoft Access moves the number of records forward or backward specified in the Offset argument.
  • When the Record argument is Go To, Microsoft Access moves to the record with the number equal to the Offset argument. The record number is shown in the record number box at the bottom of the screen.

Note If you click First, Last, or New for Record, Microsoft Access ignores any Offset number. If you enter an Offset number that is too large, Microsoft Access displays an error message. You can’t enter negative Offset numbers.

Remarks

If the focus is in a particular control in a record, this action leaves it in the same control for the new record.

You can use the New setting for the Record argument to move to the blank record at the end of a form or table so you can enter new data.

This action is similar to choosing the Go To command from the Edit menu. The First, Last, Next, Previous, and New subcommands of the Go To command have thesame effect on the selected object as the First, Last, Next, Previous, and New settings for the Record argument. You can also move to records using the navigation buttons at the bottom of the window.

You can use the GoToRecord action to make a record on a hidden form the current record if you specify the hidden form in the Object Type and Object Name arguments.

To run the GoToRecord action in Visual Basic, use the GoToRecord method of the DoCmd object.

See Also

GoToControl Action, GoToPage Action, GoToRecord Method, SelectObject Action.