Whenever the first detail line gets updated, the header onRecordChanged events gets fired again. Therefore, it only updates the first detail line's Exp. Ship Date. Below is the code. Please see if you can help me out. Thanks
Option Explicit
Public vControls As ACCPACControls
Public vORDType As Object
Public vExpShipDate As Object
Public vSession As AccpacSession
Public WithEvents vView As AccpacOE1100.ACCPACDSControl
Public WithEvents vDView As AccpacOE1100.ACCPACDSControl
Public WithEvents vCView As AccpacOE1100.ACCPACDSControl
Public strCompany As String
Public strUser As String
Public strCompany2 As String
Public blnLoaded As Boolean
Public sOrderType As String ' 4 = quote, 1 = active
Public sExpShipDate As String
Public bChangeQuoteToOrder As Boolean
Public intLine As Integer
Private Sub acOE_OnUIAppOpened()
Set vControls = acOE.UIAppControls
Set vView = acOE.UIDSControls("adsOEORDH")
Set vDView = acOE.UIDSControls("adsOEORDD")
Set vORDType = vControls("afeOEORDHtype1").GetControl
Set vExpShipDate = vControls("afeOEORDHexpdate1").GetControl
Set vSession = acOE.UISession
Set Me.Icon = acOE.UIIcon
vSession.GetSignonInfo strUser, strCompany, strCompany2
Me.Caption = strCompany & " - O/E Order Entry"
Me.Width = acOE.Width + 270
Me.Height = acOE.Height + 600
blnLoaded = True
End Sub
Private Sub fix_Detail_Exp_Date(sExpShipDate As String)
Dim intX As Integer
Dim intY As Integer
vDView.GoTop
Do Until vDView.Fetch = False
intX = intX + 1
Loop
vDView.GoTop
vDView.Read
For intY = 0 To intY = intX
vDView.Fields.FieldByName("EXPDATE").Value = sExpShipDate
vDView.Update
vDView.GoNext
Next
End Sub
Private Sub Command1_Click()
fix_Detail_Exp_Date sExpShipDate 'set the exp shipdate in details
End Sub
Private Sub vView_OnRecordChanged(ByVal eReason As AccpacCOMAPI.tagEventReason, ByVal pField As AccpacDataSrc.IAccpacDSField, ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)
Dim intX As Integer
If eReason = RSN_INIT Or eReason = RSN_READ Then
sOrderType = vORDType.Value 'get the starting value
sExpShipDate = vExpShipDate.Value
bChangeQuoteToQuote = False
End If
If eReason = RSN_FIELDCHANGE Then
If bChangeQuoteToOrder = True Then
vExpShipDate.Value = sExpShipDate 'set the exp shipdate in header
fix_Detail_Exp_Date sExpShipDate 'set the exp shipdate in details
bChangeQuoteToOrder = False
DoEvents
End If
End If
End Sub
Private Sub vView_OnRecordChanging(ByVal eReason As AccpacCOMAPI.tagEventReason, pStatus As AccpacCOMAPI.tagEventStatus, ByVal pField As AccpacDataSrc.IAccpacDSField, ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)
Dim intX As Integer
If Not pField Is Nothing Then
'capture the change
If sOrderType <> vORDType.Value Then
If sOrderType = pField And pField = "4" And vORDType.Value <> "4" Then
' MsgBox "eReason = " & eReason & " Order Type changed.", vbOKOnly, "vView_OnRecordChanging"
' MsgBox "Exp. Ship Date = " & sExpShipDate, vbOKOnly, "Exp. Ship Date"
bChangeQuoteToOrder = True
End If
End If
End If
End Sub