CanuckBuck
Registered User.
- Local time
- Yesterday, 23:47
- Joined
- Apr 27, 2019
- Messages
- 31
I have a generic date order validation function in a code module that I'm using on a number of forms. Not all of the forms have all of the dates. Is there a way to test for the existence of a control before executing a particular line (in this case a CASE statement)?
Here's my function;
If there's a better way to do this (i.e. write the function differently I'm totally open to suggestions).
Thanks in advance for any assistance.
Here's my function;
If there's a better way to do this (i.e. write the function differently I'm totally open to suggestions).
Thanks in advance for any assistance.
Code:
Function MilestoneDateOutOfOrder(frm As Form, ctl As Control) As Integer
'Check to ensure that Milestone Dates are in the
'correct (Received Date <= Assignment Date <= Assure Completeness End Date <= Technical Reivew End Date < Decision Date)
'order cancel the update and inform the user if they are not
Select Case ctl.Name
Case "txtReceivedDate"
Select Case frm.txtReceivedDate.Value
Case Is > frm.txtAssignmentDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Received Date cannot be greater than Assignment Date"
Case Is > frm.txtAssureCompletenessEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Received Date cannot be greather than Assure Completeness End Date."
Case Is > frm.txtTechnicalReviewEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Received Date cannot be greater than Technical Review End Date."
Case Is > frm.txtDecisionDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Received Date cannot be greater than Decision Date."
Case Else
MilestoneDateOutOfOrder = False
End Select
Case "txtAssignmentDate"
Select Case frm.txtAssignmentDate.Value
Case Is < frm.txtReceivedDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assignment Date cannot be less than Received Date"
Case Is > frm.txtAssureCompletenessEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assignment Date cannot be greather than Assure Completeness End Date."
Case Is > frm.txtTechnicalReviewEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assignment Date cannot be greater than Technical Review End Date."
Case Is > frm.txtDecisionDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assignment Date cannot be greater than Decision Date."
Case Else
MilestoneDateOutOfOrder = False
End Select
Case "txtAssureCompletenessEndDate"
Select Case frm.txtAssureCompletenessEndDate.Value
Case Is < frm.txtReceivedDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assure Completeness End Date cannot be less than Received Date."
Case Is < frm.txtAssignmentDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assure Completeness End Date cannot be less than Assignment Date."
Case Is > frm.txtTechnicalReviewEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assure Completeness End Date cannot be greater than Technical Review End Date"
Case Is > frm.txtDecisionDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Assure Completeness End Date cannot be greater than Decision Date."
Case Else
MilestoneDateOutOfOrder = False
End Select
Case "txtTechnicalReviewEndDate"
Select Case frm.txtTechnicalReviewEndDate.Value
Case Is < frm.txtReceivedDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Technical Review End Date cannot be less than Received Date."
Case Is < frm.txtAssignmentDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Technical Review End Date cannot be less than Assignment Date."
Case Is < frm.txtAssureCompletenessEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Technical Review End Date cannot be less than Assure Completeness End Date"
Case Is > frm.txtDecisionDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Technical Review End Date cannot be greater than Decision Date."
Case Else
MilestoneDateOutOfOrder = False
End Select
Case "txtDecisionDate"
Select Case frm.txtDecisionDate.Value
Case Is < frm.txtReceivedDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Decision Date cannot be less than Received Date."
Case Is < frm.txtAssignmentDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Decision Date cannot be less than Assignment Date."
Case Is < frm.txtAssureCompletenessEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Decision Date cannot be less than Assure Completeness End Date"
Case Is < frm.txtTechnicalReviewEndDate.Value
MilestoneDateOutOfOrder = True
MsgBox "Decision Date cannot be less than Technical Review End Date."
Case Else
MilestoneDateOutOfOrder = False
End Select
End Select
End Function