Hi,
I'm trying to insert an OE order in Accpac 5.6.
I've recorded a macro and made some modification, however when running my code I get 'Automation error. Unspecified error'
It fails at the point where I want to insert the detail line: OEORD1detail1.Insert
Would someone be able to provide a sample code of inserting an OE order or let me know what I'm doing wrong in my code below.
I'm trying to insert an OE order in Accpac 5.6.
I've recorded a macro and made some modification, however when running my code I get 'Automation error. Unspecified error'
It fails at the point where I want to insert the detail line: OEORD1detail1.Insert
Would someone be able to provide a sample code of inserting an OE order or let me know what I'm doing wrong in my code below.
Code:
mDBLinkCmpRW.OpenView "OE0520", OEORD1header
Set OEORD1headerFields = OEORD1header.Fields
mDBLinkCmpRW.OpenView "OE0500", OEORD1detail1
Set OEORD1detail1Fields = OEORD1detail1.Fields
mDBLinkCmpRW.OpenView "OE0740", OEORD1detail2
Set OEORD1detail2Fields = OEORD1detail2.Fields
mDBLinkCmpRW.OpenView "OE0180", OEORD1detail3
Set OEORD1detail3Fields = OEORD1detail3.Fields
mDBLinkCmpRW.OpenView "OE0526", OEORD1detail5
Set OEORD1detail5Fields = OEORD1detail5.Fields
mDBLinkCmpRW.OpenView "OE0522", OEORD1detail6
Set OEORD1detail6Fields = OEORD1detail6.Fields
mDBLinkCmpRW.OpenView "OE0501", OEORD1detail7
Set OEORD1detail7Fields = OEORD1detail7.Fields
mDBLinkCmpRW.OpenView "OE0502", OEORD1detail8
Set OEORD1detail8Fields = OEORD1detail8.Fields
mDBLinkCmpRW.OpenView "OE0504", OEORD1detail9
Set OEORD1detail9Fields = OEORD1detail9.Fields
mDBLinkCmpRW.OpenView "OE0503", OEORD1detail10
Set OEORD1detail10Fields = OEORD1detail10.Fields
Code:
Private Function LoadOrder(customer As String, poNumber As String, itemNo() As String, quantity() As Double, unitCost() As Currency, description As String, reference As String)
OEORD1header.Compose Array(OEORD1detail1, Nothing, OEORD1detail3, OEORD1detail2, OEORD1detail5, OEORD1detail6)
OEORD1detail1.Compose Array(OEORD1header, OEORD1detail7, OEORD1detail10, OEORD1detail8)
OEORD1detail2.Compose Array(OEORD1header)
OEORD1detail3.Compose Array(OEORD1header, OEORD1detail1)
OEORD1detail5.Compose Array(OEORD1header)
OEORD1detail6.Compose Array(OEORD1header)
OEORD1detail7.Compose Array(OEORD1detail1)
OEORD1detail8.Compose Array(OEORD1detail1, OEORD1detail9)
OEORD1detail9.Compose Array(OEORD1detail8)
OEORD1detail10.Compose Array(OEORD1detail1)
OEORD1header.Cancel
OEORD1header.Init
OEORD1detail2.Browse "", 1
OEORD1detail2.Fetch
OEORD1headerFields("CUSTOMER").Value = customer ' Customer Number
OEORD1detail2.Browse "", 1
OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number
OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch
OEORD1headerFields("PROCESSCMD").PutWithoutVerification ("1") ' Process OIP Command
OEORD1header.Process
OEORD1headerFields("SHIPTO").Value = "10GEI" ' Ship-To Location Code
OEORD1headerFields("GOFCALCTAX").PutWithoutVerification ("1") ' Perform Forced Tax Calculation
OEORD1header.Process
OEORD1headerFields("PROCESSCMD").PutWithoutVerification ("1") 'Process OIP Command
OEORD1header.Process
OEORD1headerFields("PONUMBER").Value = poNumber ' Purchase Order Number
OEORD1headerFields("EXPDATE").Value = expShipDate ' Expected Ship Date
OEORD1headerFields("ORDDATE").Value = DateSerial(2011, 6, 3) ' Order Date
OEORD1headerFields("REFERENCE").PutWithoutVerification ("ref") ' Order Reference
OEORD1headerFields("DESC").PutWithoutVerification ("desc") ' Order Description
OEORD1header.Process
OEORD1header.Insert
OEORD1header.Order = 1
OEORD1header.Read
OEORD1header.Order = 0
OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number
OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch
OEORD1detail1.RecordClear
Dim i As Integer
For i = 1 To numOfLines 'insert detail lines
OEORD1detail1.Read
OEORD1detail1.RecordCreate 0
OEORD1detail1Fields("ITEM").Value = itemNo(i) ' Item
OEORD1detail1.Process
OEORD1detail1Fields("QTYORDERED").Value = quantity(i) ' Quantity Ordered
OEORD1detail1Fields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command
OEORD1detail1.Insert
Next i
End Function