Applies ToAccess for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

You can use the GoToRecord macro action in Access desktop databases and Access web apps to make the specified record the current record in an open table, form, or query result set.

Setting

In Access desktop databases the GoToRecord macro action has the following arguments.

Action argument

Description

Object Type

The type of object that contains the record you want to make current. Select Table, Query, Form, Server View, Stored Procedure, or Function in the Object Type box. Leave this argument 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 by the Object Type argument. If you leave the Object Type argument blank, leave this argument blank also.

Record

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

Offset

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

  • When the Record argument is Next or Previous, Access moves the number of records forward or backward specified in the Offset argument.

  • When the Record argument is Go To, 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 window.

Note: If you use the First, Last, or New setting for the Record argument, Access ignores the Offset argument. If you enter an Offset argument that is too large, Access displays an error message. You can't enter negative numbers for the Offset argument.

In Access web apps, the GoToRecord macro action has only one argument.

Action argument

Description

Record

The record to make the current record. Select Previous, Next, First, or Last in the Record box. The default is Next.

Remarks

If the focus is in a particular control in a record, this macro 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.

In Access desktop databases, this action is similar to clicking the arrow below the Find button on the Home tab and then clicking Go To. The First, Last, Next, Previous, and New Record subcommands of the Go To command have the same effect on the selected object as the First, Last, Next, Previous, and New settings for the Record argument. You can also move to records by using the navigation buttons at the bottom of the window.

In Access desktop databases 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 a Visual Basic for Applications (VBA) module, use the GoToRecord method of the DoCmd object.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.