I have used a similar type coding for creating my own custom CauseValidation
property and Validate event within Access forms to similate VB6 version of
that property and event respectively.
Here's the code I have so far put in to address the issue, which has
actually opened up other possibilities and given me some other ideas as to
how to deal with some of the other issues that I have seen happen as well as
thought of happening:
Child Source Class Property to refer to Parent Collection Object
-----Start Of Code------
Public Property Set prp_rw_Parent(ByVal l_objWorkOrders As clsWorkOrders)
Set m_objWorkOrders = l_objWorkOrders
End Property
Public Property Get prp_rw_Parent() As clsWorkOrders
Set prp_rw_Parent = m_objWorkOrders
End Property
-----End Of Code------
Method to call on Parent Collection Object to raise the event both before
and after updating the child object. The before event so as the previous
step could be recorded into other places that needs to be recorded, and the
after update to allow for other objects get data about the current new step
of the order and what they may need to do with their portion about the order
(I.e. If it went from inactive to active, must make it active in their own
respective objects).
-----Start Of Code------
Public Function fncRecordStatusReason(ByVal l_lngStatus As
g_enmWorkOrderStatus, Optional ByVal l_strReasonCode As String = "") As Long
Dim l_lngActiveBeforeChange As Long, l_lngActiveAfterChange As Long
If m_dteStartTime > 0 Then
l_lngActiveBeforeChange = 1
Else
l_lngActiveBeforeChange = 0
End If
m_dteEndTime = Now()
If (m_lngStatus = l_lngStatus And m_strReasonCode = l_strReasonCode And
m_dteStartTime > 0) Or m_dteStartTime > m_dteEndTime Or _
VBA.Format(m_dteStartTime, "dd/mm/yyyy hh:mm:ss") =
VBA.Format(m_dteEndTime, "dd/mm/yyyy hh:mm:ss") Then
Else
m_objWorkOrders.pcdWorkOrderStatusBeforeUpdate Me
pcdRecordProductionTime
End If
m_lngStatus = l_lngStatus
m_strReasonCode = l_strReasonCode
Select Case l_lngStatus
Case g_enmWorkOrderStatus.lngWorkOrderRunEnum,
g_enmWorkOrderStatus.lngWorkOrderRunIdleEnum,
g_enmWorkOrderStatus.lngWorkOrderRunProblemEnum, _
g_enmWorkOrderStatus.lngWorkOrderSetupEnum,
g_enmWorkOrderStatus.lngWorkOrderSetupIdleEnum,
g_enmWorkOrderStatus.lngWorkOrderSetupProblemEnum
If l_strReasonCode = "P" Or l_strReasonCode = "T" Then
m_dteStartTime = 0
l_lngActiveAfterChange = 0
Else
m_dteStartTime = m_dteEndTime
l_lngActiveAfterChange = 1
End If
Case Else
m_dteStartTime = 0
l_lngActiveAfterChange = 0
End Select
m_objWorkOrders.pcdWorkOrderStatusAfterUpdate Me,
l_lngActiveAfterChange - l_lngActiveBeforeChange
fncRecordStatusReason = l_lngActiveAfterChange - l_lngActiveBeforeChange
End Function
-----End Of Code------
Parent Collection Object Event Codes
-----Start Of Code------
Public Event evtWorkOrderStatusBeforeUpdate(ByVal l_objWorkOrder As
clsWorkOrder)
Public Event evtWorkOrderStatusAfterUpdate(ByVal l_objWorkOrder As
clsWorkOrder, ByVal l_lngOrderActiveStatusChangeValue As Long)
-----End Of Code------
The raising of the events withing the Parent Collection Object
-----Start Of Code------
Public Sub pcdWorkOrderStatusAfterUpdate(ByVal l_objWorkOrder As
clsWorkOrder, ByVal l_lngOrderActiveStatusChangeValue As Long)
RaiseEvent evtWorkOrderStatusAfterUpdate(l_objWorkOrder,
l_lngOrderActiveStatusChangeValue)
End Sub
Public Sub pcdWorkOrderStatusBeforeUpdate(ByVal l_objWorkOrder As
clsWorkOrder)
RaiseEvent evtWorkOrderStatusBeforeUpdate(l_objWorkOrder)
End Sub
-----End Of Code------
The Sink Class Module of the Declaration of the Source Class object
-----Start Of Code------
Dim WithEvents m_WorkOrders As clsWorkOrders
-----End Of Code------
The signature line of the Sink Class Module receiving the before update
code.
-----Start Of Code------
Private Sub m_WorkOrders_evtWorkOrderStatusBeforeUpdate(ByVal l_objWorkOrder
As clsWorkOrder)
-----End Of Code------
--
Thanks,
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000