我试图弄清楚如何使用组合框将记录设置为“已完成”状态后将其锁定。我在[Date Completed]字段中使用时间戳记,并且想要对其进行锁定,以便一旦设置了该字段就无法再次更改。 如果没有这个或类似的东西,您可以继续选择“进行中”或“已完成”,并不断更新时间,而我试图阻止这种情况的发生。
我尝试了以下操作,但是它锁定了所有记录。
Private Sub Staus_BeforeChange(Cancel As Integer)
'Private Sub Status_Change()
Dim rs As DAO.Recordset
Dim ValueList()
'In progress
If [Status] = 10 Then
[StartDate] = Now()
'Completed
ElseIf [Status] = 100 Then
[DateCompleted] = Now()
'Lock record if completed status
'If Form.CurrentRecord.[Status] = 100 Then
'Form.CurrentRecord.AllowEdits = False
'Else
'Form.CurrentRecord.AllowEdits = True
'End If
'Transferred
ElseIf [Status] = -10 Then
[DateTransferred] = Now()
'Copy Record without completed date
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
[Status] = 0
[StartDate] = Null
[User ID] = "Unassigned"
[DateTransferred] = Null
[DueDate] = [DueDate]
MsgBox "The following Task has been transferred:" & " " & Me.[Company] & " " & Me.[Task Name]
'Waiting
ElseIf [Status] = 50 Then
[DateCompleted] = Now()
End If
Forms![frmTasks].Form.Requery
Forms![frmTasks].Form.Refresh
End Sub
Public beforeValueChange As Integer
beforeValueChange = Me.[Status]
End Sub
Private Sub Status_AfterUpdate()
If Not IsNull(Me.[DateCompleted]) Then
Me.[Status] = beforeValueChange
End If
End Sub
我非常感谢您的帮助或朝着正确的方向前进。 谢谢!!! -德克
答案 0 :(得分:1)
如果这不能阻止用户进行更改,那么可能是下面的内容?
qDebug()