Thanks for ur reply,
It through an error at OEORD1header.Init.
----------------------------------------------
On Error GoTo ACCPACErrorHandler
Dim objsess As xapiSession
Set objsess = New xapiSession
Call objsess.Open("ADMIN", "ADMIN", "ADATTS", Date, 1)
Dim OEORD1header As ACCPACXAPILib.xapiView
Dim OEORD1headerFields As ACCPACXAPILib.xapiFields
Set OEORD1header = objsess.OpenView("OE0520", "OE"

Set OEORD1headerFields = OEORD1header.Fields
Dim OEORD1detail1 As ACCPACXAPILib.xapiView
Dim OEORD1detail1Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail1 = objsess.OpenView("OE0500", "OE"

Set OEORD1detail1Fields = OEORD1detail1.Fields
Dim OEORD1detail2 As ACCPACXAPILib.xapiView
Dim OEORD1detail2Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail2 = objsess.OpenView("OE0740", "OE"

Set OEORD1detail2Fields = OEORD1detail2.Fields
Dim OEORD1detail3 As ACCPACXAPILib.xapiView
Dim OEORD1detail3Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail3 = objsess.OpenView("OE0180", "OE"

Set OEORD1detail3Fields = OEORD1detail3.Fields
Dim OEORD1detail4 As ACCPACXAPILib.xapiView
Dim OEORD1detail4Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail4 = objsess.OpenView("OE0680", "OE"

Set OEORD1detail4Fields = OEORD1detail4.Fields
Dim OEORD1headerComps(8) As ACCPACXAPILib.xapiView
Set OEORD1headerComps(0) = OEORD1detail1
Set OEORD1headerComps(1) = OEORD1detail4
Set OEORD1headerComps(2) = OEORD1detail3
Set OEORD1headerComps(3) = OEORD1detail2
Set OEORD1headerComps(4) = Nothing
Set OEORD1headerComps(5) = Nothing
Set OEORD1headerComps(6) = Nothing
Set OEORD1headerComps(7) = Nothing
Set OEORD1headerComps(8) = Nothing
OEORD1header.Compose OEORD1headerComps
Dim OEORD1detail1Comps(1) As ACCPACXAPILib.xapiView
Set OEORD1detail1Comps(0) = OEORD1header
Set OEORD1detail1Comps(1) = Nothing
OEORD1detail1.Compose OEORD1detail1Comps
Dim OEORD1detail2Comps(1) As ACCPACXAPILib.xapiView
Set OEORD1detail2Comps(0) = OEORD1header
Set OEORD1detail2Comps(1) = Nothing
OEORD1detail2.Compose OEORD1detail2Comps
Dim OEORD1detail3Comps(2) As ACCPACXAPILib.xapiView
Set OEORD1detail3Comps(0) = OEORD1header
Set OEORD1detail3Comps(1) = Nothing
Set OEORD1detail3Comps(2) = OEORD1detail1
OEORD1detail3.Compose OEORD1detail3Comps
Dim OEORD1detail4Comps(2) As ACCPACXAPILib.xapiView
Set OEORD1detail4Comps(0) = OEORD1header
Set OEORD1detail4Comps(1) = Nothing
Set OEORD1detail4Comps(2) = OEORD1detail1
OEORD1detail4.Compose OEORD1detail4Comps
OEORD1header.Order = 0
OEORD1header.Cancel
OEORD1header.Init
OEORD1detail1.Order = 0
OEORD1headerFields("CUSTOMER"

.Value = "AL110-1" ' Customer Number
OEORD1headerFields("TEMPLATE"

.PutWithoutVerification (""

' Template Code
OEORD1headerFields("TYPE"

.PutWithoutVerification ("1"

' Order Type
OEORD1headerFields("QTEXPDATE"

.PutWithoutVerification (Empty) ' Quote Expiration Date
OEORD1headerFields("ORDDATE"

.PutWithoutVerification (#6/17/2003#) ' Order Date
OEORD1headerFields("FOB"

.PutWithoutVerification (""

' Free On Board Point
OEORD1headerFields("LOCATION"

.PutWithoutVerification (""

' Default Location Code
OEORD1headerFields("LOCDESC"

.PutWithoutVerification (""

' Location Code Desc.
OEORD1headerFields("ONHOLD"

.PutWithoutVerification ("0"

' On Hold Status
OEORD1headerFields("DESC"

.PutWithoutVerification (""

' Order Description
OEORD1headerFields("COMMENT"

.PutWithoutVerification (""

' Order Comment
OEORD1headerFields("REFERENCE"

.PutWithoutVerification (""

' Order Reference
OEORD1headerFields("AUTOTAXCAL"

.PutWithoutVerification ("1"

' Auto-Tax Calculation Status
OEORD1headerFields("OPTIONAL2"

.Value = "ASE" ' Optional Field 2
OEORD1header.Insert
OEORD1headerFields("CUSTOMER"

.PutWithoutVerification ("AL110-1"

' Customer Number
OEORD1headerFields("OPTIONAL2"

.PutWithoutVerification ("ASE"

' Optional Field 2
Exit Sub
ACCPACErrorHandler:
Dim Errors, objError
Set Errors = objsess.Errors
'Dim Error As Variant
If Errors.Count = 0 Then
MsgBox Err.Description
Else
For i = 0 To Errors.Count - 1
Set objError = Errors.Item(i)
MsgBox objError.Description & " (" & objError.Priority & "

"
Next
'For Each Error In Errors
' MsgBox Error.Description
'Next
Errors.Clear
End If
Resume Next