简体   繁体   English

表单打开时更改表中的记录-记录锁定

[英]Changes to record in table while form is open - record locking

I have a design for a multi-user database: 1. Form A is used to update Table A and Table B (simultaneously On Click) 2. Form B is used to review Table B, approve records, then delete them from Table B 我有一个用于多用户数据库的设计:1.表单A用于更新表A和表B(同时单击时)2.表单B用于查看表B,批准记录,然后从表B中删除它们

The problem is if Form B is opened on a record (with Primary Key CASENUMBER) and the record for that CASENUMBER is edited in Form A. 问题是,如果在记录(具有主键CASENUMBER)上打开了窗体B,并且该CASENUMBER的记录在窗体A中进行了编辑。

How do I put a lock on a specific record so that if it is being viewed in a form it cannot be viewed/edited in another? 如何锁定特定记录,以便如果以某种形式查看它,则不能以其他形式查看/编辑它?

To expand on your syntax question: 扩展您的语法问题:

First you would need to modify your SQL statement to include the IN_USE_A and IN_USE_B . 首先,您需要修改SQL语句以包含IN_USE_AIN_USE_B Once a record is pulled but before it is put into the form, you would set a recordset based on that record and then make the field for each table true. 一旦拉出一条记录,但在将其放入表单之前,您将基于该记录设置一个记录集,然后将每个表的字段设置为true。

Dim strSQL As String
Dim myR As Recordset

strSQL = "SELECT * FROM TABLE_A WHERE criteria_here"

Set myR = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
'myR is now that record and can be manipulated/data pulled from

myR.Edit
myR![IN_USE_A] = TRUE
myR.Update

'perform tasks and such

'then just before closing

myR.Edit
myR![IN_USE_A] = FALSE
myR.Update

Set myR = Nothing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM