Table of contents
TOC
折叠目录
展开目录

Form.RecordLocks 属性 (访问)Form.RecordLocks Property (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

可以使用RecordLocks属性确定锁定记录的方式以及当两个用户试图同时编辑同一条记录时,会发生什么情况。读/写。You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.

语法Syntax

表达式记录锁定expression. RecordLocks

表达式_一个表示窗体对象的变量。_expression A variable that represents a Form object.

注解Remarks

当编辑记录时,Microsoft Access 会自动锁定该记录,以防其他用户在完成之前对其进行更改。对于窗体, RecordLocks属性指定在多用户数据库中的数据进行更新时,如何锁定基础表或基础查询中的记录When you edit a record, Microsoft Access can automatically lock that record to prevent other users from changing it before you are finished. For forms, the RecordLocks property specifies how records in the underlying table or query are locked when data in a multiuser database is updated

RecordLocks属性仅适用于窗体、 报表或查询,Microsoft Access 数据库中。The RecordLocks property only applies to forms, reports, or queries in a Microsoft Access database.

RecordLocks属性使用以下设置。The RecordLocks property uses the following settings.

设置SettingVisual BasicVisual Basic说明Description
不锁定No Locks00(默认值)在窗体中,两个或多个用户可以同时编辑同一条记录。这也称为"开放式"锁定。如果两个用户试图将更改保存到同一条记录时,Microsoft Access 将显示一条消息给用户尝试保存记录的第二个用户。此用户可以放弃该记录,将记录复制到剪贴板,或替换其他用户所做的更改。此设置通常使用在只读窗体或单用户数据库中。它还用于在多用户数据库允许多个用户能够同时对同一条记录进行更改。(Default) In forms, two or more users can edit the same record simultaneously. This is also called "optimistic" locking. If two users attempt to save changes to the same record, Microsoft Access displays a message to the user who tries to save the record second. This user can then discard the record, copy the record to the Clipboard, or replace the changes made by the other user. This setting is typically used on read-only forms or in single-user databases. It is also used in multiuser databases to permit more than one user to be able to make changes to the same record at the same time.
所有记录All Records11当窗体在窗体视图或数据表视图中打开时,基础表或查询中的所有记录都被锁定。尽管用户可以读取记录,但是在关闭窗体之前,没有人能编辑、添加或删除任何记录。All records in the underlying table or query are locked while the form is open in Form view or Datasheet view. Although users can read the records, no one can edit, add, or delete any records until the form is closed.
已编辑的记录Edited Record22(仅用于窗体和查询)只要用户开始编辑某条记录中的任一字段,即会锁定该页记录,直到用户移动到其他记录,锁定才会解除。这样一条记录一次只能由一位用户进行编辑。这也称为“保守式”锁定。(Forms and queries only) A page of records is locked as soon as any user starts editing any field in the record and stays locked until the user moves to another record. Consequently, a record can be edited by only one user at a time. This is also called "pessimistic" locking.

请注意 已打开的窗体或报表的RecordLocks属性更改将导致自动重新创建记录集。Note Changing the RecordLocks property of an open form or report causes an automatic recreation of the recordset.

在只有一个人使用基础表或基础查询,或者对数据进行更改的情况下,可以对窗体使用“不锁定”设置。You can use the No Locks setting for forms if only one person uses the underlying tables or queries or makes all the changes to the data.

在多用户数据库中,如果想使用开放式锁定并对试图编辑窗体上同一条记录的用户发出警告,可以使用“不锁定”设置。如果想防止两个或更多用户同时编辑数据,则可以使用“已编辑的记录”设置。In a multiuser database, you can use the No Locks setting if you want to use optimistic locking and warn users attempting to edit the same record on a form. You can use the Edited Record setting if you want to prevent two or more users editing data at the same time.

在窗体视图或数据表视图中,每条锁定记录在它的记录选定器中都有一个锁定指示器。In Form view or Datasheet view, each locked record has a locked indicator in its record selector.

若要更改窗体的默认RecordLocks属性设置,单击工具菜单上的选项,单击选项对话框上的高级选项卡,然后选择在默认记录锁定下所需的选项.To change the default RecordLocks property setting for forms, click Options on the Tools menu, click the Advanced tab on the Options dialog box, and then select the desired option under Default record locking.

在窗体、 报表或查询从开放式数据库连接(ODBC) (ODBC) 数据库中的数据被视为不锁定设置选择,不管RecordLocks属性设置。Data in a form, report, or query from an Open Database Connectivity (ODBC) database is treated as if the No Locks setting were chosen, regardless of the RecordLocks property setting.

示例Example

下面的示例将"雇员"窗体的RecordLocks属性设置为已编辑的记录 (当任何用户开始编辑记录中的任何字段并保持锁定状态,直到用户移到另一个记录被锁定记录)。The following example sets the RecordLocks property of the "Employees" form to Edited Record (a page of records is locked as soon as any user starts editing any field in the record and stays locked until the user moves to another record).

Forms("Employees").RecordLocks = 2

另请参阅See also

概念Concepts

窗体对象Form Object

© 2018 Microsoft