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!

create OE Order with Macro - Error. Insert' of object 'IAccpacView' f

Status
Not open for further replies.

thocom

Programmer
Jul 22, 2011
2
Hi,
I'm trying a macro to insert an OE order detail in Accpac 6.0
,however when running my code error "Method 'Insert' of object 'IAccpacView' fail"

It fails at to insert the detail line OEORD1detail1.Insert

My Code:::
-----------------------------------------------
Sub MainSub()


On Error GoTo ACCPACErrorHandler

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

Dim OEORD1header As AccpacCOMAPI.AccpacView
Dim OEORD1headerFields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail1 As AccpacCOMAPI.AccpacView
Dim OEORD1detail1Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail3 As AccpacCOMAPI.AccpacView
Dim OEORD1detail3Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail2 As AccpacCOMAPI.AccpacView
Dim OEORD1detail2Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail5 As AccpacCOMAPI.AccpacView
Dim OEORD1detail5Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail6 As AccpacCOMAPI.AccpacView
Dim OEORD1detail6Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail7 As AccpacCOMAPI.AccpacView
Dim OEORD1detail7Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail8 As AccpacCOMAPI.AccpacView
Dim OEORD1detail8Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail9 As AccpacCOMAPI.AccpacView
Dim OEORD1detail9Fields As AccpacCOMAPI.AccpacViewFields

Dim OEORD1detail10 As AccpacCOMAPI.AccpacView
Dim OEORD1detail10Fields As AccpacCOMAPI.AccpacViewFields


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


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, Nothing)
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.Cancel
OEORD1header.Init
OEORD1header.Order = 1
OEORD1header.Read
OEORD1header.Order = 0

OEORD1detail2.Browse "", 1
OEORD1detail2.Fetch
OEORD1headerFields("CUSTOMER").Value = "AR01-0259-ME" ' Customer Number
OEORD1headerFields("ORDNUMBER").Value = "A74/135" 'Order Number

OEORD1detail2.Browse "", 1
OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number
OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch
OEORD1headerFields("PROCESSCMD").PutWithoutVerification ("1") ' Process OIP Command
OEORD1header.Process
OEORD1header.Read

OEORD1detail1.RecordClear
OEORD1detail1.Read
OEORD1detail1.RecordCreate 0

OEORD1detail1Fields("ITEM").Value = "001074001" ' Item
OEORD1detail1Fields("LOCATION").Value = "A03" ' Location
OEORD1detail1Fields("CATEGORY").Value = "SPARE" ' Location
OEORD1detail1Fields("QTYORDERED").Value = 1 ' Quantity Ordered
OEORD1detail1Fields("PRIUNTPRC").Value = "9000000.000000" ' Pricing Unit Price

OEORD1detail1Fields("PROCESSCMD").PutWithoutVerification ("1")

OEORD1detail1.Insert
OEORD1detail1.Read
OEORD1detail1.Init
OEORD1headerFields("GOFCALCTAX").PutWithoutVerification ("1") ' Perform Forced Tax Calculation
OEORD1header.Process
OEORD1headerFields("PROCESSCMD").PutWithoutVerification ("1") 'Process OIP Command
OEORD1header.Process

OEORD1header.Process
OEORD1header.Update

Exit Sub
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long

If Errors Is Nothing Then
MsgBox Err.Description
Else
lCount = Errors.Count

If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next
End If



End Sub
 
The code looks correct at first glance. Try entering that order manually into Accpac and see what message you get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top