Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Order Type change in OE ?

Status
Not open for further replies.

vbdbcoder

Programmer
Nov 23, 2006
247
US
I have a request to detect the change on the Order Type drop-down combo box in OE screen. When the order type is changed from "Quote" to "Active", then I need to do something special. What events to use to tell me that the users change the value in the order type drop-down?

 
Accpac version is 6.0. I will use VB6.0 and OE ocx to create a custom program.
 
The Exp. Ship Date field is changed to today's date in Active Order when flipping from Quote. It should be the same date value in the Quote. Both the header and details' exp. ship dates were changed to today's date. The request is to change the Active Order's Exp. Ship date back to the Quote's date value.
 
Okay - go with Tuba's direction. I just wanted to make sure that a database trigger wouldn't be able to help.
 
Thanks.

I could capture the Exp. Ship Date value from the Quote in .OnRecordChanging event. I could update the Header's Exp. Ship Date in the OnRecordChanged events. I am having problem with updating the Details' Exp. Ship Date. Trying to figure out where to fire the Details' Exp. Ship Date update.
 
You'll want to access the datasource connected to the detail lines. You can still do the update from within the header data source's OnRecordChanging event, if you like.
 
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
 
There are a number of ways to handle this. One option is to move your code to the OnRecordChanged event instead of OnRecordChanging.

Another option is to use a flag variable that you set when you start to update the detail lines so that when you end up in the .OnRecordChanging event you know not to try changing the detail lines again. Reset the flag when you're done updating the detail lines.

On the detail data source you're going to want to .SetFireEvents False otherwise you'll get errors when you have more detail lines than what can fit on the screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top