如何锁定在子窗体,当窗体加载特定行?窗体、加载

2023-09-09 21:23:48 作者:冷 眸 ゞ

我有一个包含记录有是子窗体/否字段显示为子窗体上的复选框。当主要形式加载,我需要锁定所有选中的字段,以便用户不能撤消什么previous用户所做的:他们应该只能够查看/取消被取消选中在thier会话的开始,这些箱子。

I have a subform containing records with a Yes/No field displayed as a checkbox on the subform. When the main form is loaded, I need to lock all checked fields so that the user cannot undo what a previous user did: they should only be able to check/uncheck the boxes that were unchecked at the start of thier session.

是否有可能遍历子窗体中的所有记录,当窗体加载锁定选择基于字段值的记录?

Is it possible to iterate through all the records in a subform and lock the records selectively based on the field value when a form is loaded?

我知道我可以把类似

If (Me.chkItemReceived.Value = -1) Then
        Me.chkItemReceived.Locked = True
Else
        Me.chkItemReceived.Locked = False
End If

在窗体成为当前事件,但这prevents从取消选中一箱他们可能无意中检查用户。我可以通过子窗体中的记录重复,但无法弄清楚如何锁定在行级的记录。

in the subform OnCurrent event but this prevents the user from unchecking a box they may have checked accidently. I can iterate through the records on the subform but can't figure out how to lock the records at row-level.

我的另一个解决方案是将表格分为当然两个子表单 - 物品托运物品与不却​​宁愿保持它的一种形式

My other solution is to split the form into two subforms of course - items checked vs. items not but would rather keep it to the one form.

感谢您的帮助!

推荐答案

没有,有没有办法让锁定在MS Access的界面特定的行(或记录)。如果你在一个记录改变控件的属性,它改变它在子窗体中的所有记录上。

No, there is no way to have specific rows (or records) locked in the GUI in MS Access. If you change the properties of a control on one record, it changes it on all records in the subform.

我不认为你甚至可以摆脱做行级直接在基础表的锁定。通常情况下,锁定从编辑你的记录做了prevent他人。但是从他们的编辑在这种情况下,你想prevent自己。

I don't think you could even get away with doing row-level locking directly on the underlying table. Typically, locking is done to prevent others from editing your records. But in this case, you are trying to prevent yourself from editing them.

您描述(成为当前和独立的子表单),这两种方法都可能是你最好的选择。对于的code清洁度,我会选择后者。

The two methods you describe (OnCurrent and separate SubForms) are probably your best options. For cleanliness of the code, I'd choose the latter.