据我了解,编辑记录基本上有3个阶段:
用于启用/禁用表单上数据编辑的逻辑表可能类似于:
+----------+---------------+---------------+---------------+
| User | 1:In Progress | 2:TBC | 3:Locked |
+----------+---------------+---------------+---------------+
| Dept A | Enable | Disable | Disable |
+----------+---------------+---------------+---------------+
| Dept B | Disable | Enable | Disable |
+----------+---------------+---------------+---------------+
从那里,我们看到除了状态为In Progress的 Dept A或状态为To Be Completed的Dept B之外,控件应始终禁用。
要实现这样的事情,您可以简单地将EditStatus
具有这些状态的字段添加到您的数据表中,然后在OnCurrent
您的表单中,根据需要锁定/解锁控件。
例如:
Private Sub Form_Current()
Dim controlLock As Boolean
controlLock = ((currentUserDepartment = "A") And (EditStatus = 1)) _
Or _
((currentUserDepartment = "B") And (EditStatus = 2))
' Now we can enable/disable çontrols '
' Alternatively, use the Locked property instead of Enabled '
txtEditJobName.Enabled = controlLock
txtEditJobDate.Enabled = controlLock
'... etc ... '
End Sub
如果需要锁定整个表单而不是单个控件,则更简单:
Private Sub Form_Current()
Me.AllowEdits = ((currentUserDepartment = "A") And (EditStatus = 1)) _
Or _
((currentUserDepartment = "B") And (EditStatus = 2))
End Sub
我会让你弄清楚细节,并根据你的实际情况进行调整,但你应该从中得到一个笑话。