GoToRecord 宏操作

适用于:Access 2013、Office 2013

可以使用 GoToRecord 操作将指定记录设置为打开的表、窗体或查询结果集中的当前记录。

Setting

GoToRecord 操作具有下列参数。

操作参数

说明

对象类型

要设置为当前记录的记录所在的数据库对象的类型。 请在“宏生成器”窗格“操作参数”部分的“对象类型”框中单击“表”“查询”“窗体”“服务器视图”“存储过程”“函数”。 如果将此参数留空,则会选择活动对象。

对象名称

要设置为当前记录的记录所在的对象的名称。 “对象名称”框显示属于“对象类型”参数所选类型的当前数据库中的所有对象。 如果将“对象类型”参数留空,则也要将此参数留空。

Record

要设置为当前记录的记录。 请单击“记录”框中的“上一个”“下一个”“第一个”“最后一个”“转至”“新建”。 默认值为“下一个”

Offset

一个整数或求值结果为整数的表达式。 表达式必须以等号 (=) 开头。 此参数指定要设置为当前记录的记录。 “偏移量”参数有两种用法:

  • 当“记录”参数为“下一个”“上一个”时,Microsoft Office Access 2007 会向前或向后移动“偏移量”参数指定的记录数。

  • 当“记录”参数为“转至”时,Access 会移到编号等于“偏移量”参数的记录。 记录编号显示在窗口底部的记录编号框中。

    注意:如果对 Record 参数使用 FirstLastNew 设置,Access 将忽略 Offset 参数。 如果输入的“偏移量”参数过大,Access 将显示一条错误消息。 不能为“偏移量”参数输入负数。

  • 当“记录”参数为“下一个”“上一个”时,Microsoft Office Access 2007 会向前或向后移动“偏移量”参数指定的记录数。

  • 当“记录”参数为“转至”时,Access 会移到编号等于“偏移量”参数的记录。 记录编号显示在窗口底部的记录编号框中。

备注

如果焦点位于记录中的某个特定控件中,此操作会将焦点留在新记录的相同控件中。

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 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.

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.

要在 Visual Basic for Applications (VBA) 模块中运行 GoToRecord 操作,请使用 DoCmd 对象的 GoToRecord 方法。