VBA MS访问功能

时间:2010-10-12 14:27:25

标签: ms-access ms-access-2003

以下函数用于评估过程CheckEventDataIntegrity调用的日期。这仅适用于事件,但现在我想添加partnumber和事件类型。意味着它应该用事件和partnumber来评估日期。我怎么能这样做?

'-----------------------------
'-----------------------------
' 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 '目的:验证正在遵循流程逻辑,这将检查顺序 “----------------------------- 函数CheckEventDataIntegrity(fl1 As Boolean) On Error GoTo CheckEventDataIntegrity_Error

Do While fl1 = True

'事件类型#1a           如果我!EventTypeSelected =“1a Assign - To Checker Queue”那么            如果EvaluateDates(“1从Detailer接收新”)= False然后'包装器尚未分配给Checker                CheckEventDataIntegrity = False                退出功能                其他                 'CheckEventDataIntegrity = True                退出做                    万一                    万一 '事件类型#2         如果我!EventTypeSelected =“2 ReV - Assignment”那么         如果EvaluateDates(“1从Detailer接收新”)= False那么'包装器尚未分配给审阅者                 CheckEventDataIntegrity = False                 退出功能                 其他                 退出做            万一            结束如果

----

------

-----


fl1 =假     环     '没有失败的考验     CheckEventDataIntegrity = True

On Error GoTo 0 退出功能 CheckEventDataIntegrity_Error:     MsgBox“错误”& Err.Number& “(& Err.Description&”)在VBA文档Form_frmEventLog_Input的过程CheckEventDataIntegrity中“ 结束功能

我可以在评估函数中添加partnumber:

Private Function EvaluateDates(et As String, pn As String)
    varx = DLookup("[EventDate]", "tblEventLog", "[TrackingNumber] = '" & Me!TrackingNumber & "' And [EventTypeSelected] = '" & et & "' And [PartNumber] = '" & Pn & "'")

但是如何在CheckEventDataIntegrity过程中实现它?

1 个答案:

答案 0 :(得分:0)

我正在学习VBA,正在开展我的第一个项目。

我得到了答案。