以下函数用于评估由过程 CheckEventDataIntegrity 调用的日期。这仅适用于事件,但现在我想添加部件号和事件类型。意味着它应该使用事件和零件号评估日期。我该怎么做?
'-----------------------------
'-----------------------------
' Function : EvaluateDates
' Purpose : flags date sequencing errors, called by CheckEventDataIntegrity
'-----------------------------
Private Function EvaluateDates(et As String)
Dim varx As Variant
On Error GoTo EvaluateDates_Error
varx = DLookup("[EventDate]", "tblEventLog", "[TrackingNumber] = '" & Me!TrackingNumber & "' And [EventTypeSelected] = '" & et & "'")
If IsNull(varx) Then ' predecessor event does not exist
displayMsgBox = _
MsgBox("No '" & et & "' event has been Recorded. Please correct.", _
vbCritical)
EvaluateDates = False
Exit Function
End If
If varx > Me!EventDate Then ' predecessor event exists but date is after date being posted
displayMsgBox = _
MsgBox("Chronological Error. Previously posted '" & et & "' event has date stamp that is later than date stamp of completion event you are now attempting to post. Please verify date of event you are now posting. If it is correct than contact admin.", _
vbCritical)
EvaluateDates = False
Exit Function
End If
EvaluateDates = True
On Error GoTo 0
Exit Function
EvaluateDates_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure EvaluateDates of VBA Document Form_frmEventLog_Input"
End Function
CheckEventDataIntegrity 过程调用如下:
'-------------------------------- '-------- ---------- ' 过程:CheckEventDataIntegrity ' 目的: 验证流程逻辑是否被遵循,这会检查排序 '--------- -------- Function CheckEventDataIntegrity(fl1 As Boolean) On Error GoTo CheckEventDataIntegrity_Error
Do While fl1 = True
'事件类型 #1a If Me!EventTypeSelected = "1a Assign - To Checker Queue" Then If EvaluateDates("1 Receive NEW from Detailer") = False Then ' 包装器尚未分配给 Checker CheckEventDataIntegrity = False Exit Function Else ' CheckEventDataIntegrity = True Exit Do End If End If 'event type #2 If Me!EventTypeSelected = "2 ReV - Assignment" Then If EvaluateDates("1 Receive NEW from Detailer") = False Then ' 包装器尚未分配给审阅者 CheckEventDataIntegrity = False 退出函数 Else Exit Do End If End If
----
------
-----
fl1 = False Loop '没有失败测试 CheckEventDataIntegrity = True
On Error GoTo 0 Exit Function CheckEventDataIntegrity_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CheckEventDataIntegrity of VBA Document Form_frmEventLog_Input" End Function
我可以在评估函数中添加零件编号,如下所示:
Private Function EvaluateDates(et As String, pn As String)
varx = DLookup("[EventDate]", "tblEventLog", "[TrackingNumber] = '" & Me!TrackingNumber & "' And [EventTypeSelected] = '" & et & "' And [PartNumber] = '" & Pn & "'")
但是如何在 CheckEventDataIntegrity 过程中实现它?