Hi,
I am working on VB program which insert data into AccPac OE.
Now I can insert OE Header,but details data always give me an error message "Order Detail": Record not Found(3)".
My code is the following:
OEORD0520.Init
SetOEFields OEORD0520_Fields, Rs_0520 ' Set the fields
OEORD0520_Fields"OPTIONAL2").Value "1" OEORD0520.Insert
orderID = OEORD0520_Fields("OrdNumber").Value
Debug.Print orderID
OEORD0520.Cancel
OEORD0520.Browse "ORDNUMBER = " & orderID, 1
OEORD0520.Fetch
Dim strUniqueID As String
strUniqueID = OEORD0520.Fields("ORDUNIQ").Value ' ORDUNIQ
Debug.Print strUniqueID
If Not (Rs_0500.BOF And Rs_0500.EOF) Then
Rs_0500.Filter = "ordUniq= " & .Fields("orduniq").Value
Do While Not Rs_0500.EOF
OEORD0500.Init
OEORD0500_Fields("ORDUNIQ").Value = strUniqueID
SetOEFields OEORD0500_Fields, Rs_0500
OEORD0500.Insert
Rs_0500.MoveNext
Loop
End If
Private Sub SetOEFields(OEFields As ACCPACXAPILib.xapiFields, Rs As ADODB.Recordset)
With Rs
For i = 0 To .Fields.count - 1
Select Case .Fields(i).Name
Case "rectype"
Case "ordnumber"
Case "orduniq"
Case Else
OEFields(.Fields(i).Name).Value = .Fields(i).Value
End Select
Next
End With
End Sub
Appriciate any help!
I am working on VB program which insert data into AccPac OE.
Now I can insert OE Header,but details data always give me an error message "Order Detail": Record not Found(3)".
My code is the following:
OEORD0520.Init
SetOEFields OEORD0520_Fields, Rs_0520 ' Set the fields
OEORD0520_Fields"OPTIONAL2").Value "1" OEORD0520.Insert
orderID = OEORD0520_Fields("OrdNumber").Value
Debug.Print orderID
OEORD0520.Cancel
OEORD0520.Browse "ORDNUMBER = " & orderID, 1
OEORD0520.Fetch
Dim strUniqueID As String
strUniqueID = OEORD0520.Fields("ORDUNIQ").Value ' ORDUNIQ
Debug.Print strUniqueID
If Not (Rs_0500.BOF And Rs_0500.EOF) Then
Rs_0500.Filter = "ordUniq= " & .Fields("orduniq").Value
Do While Not Rs_0500.EOF
OEORD0500.Init
OEORD0500_Fields("ORDUNIQ").Value = strUniqueID
SetOEFields OEORD0500_Fields, Rs_0500
OEORD0500.Insert
Rs_0500.MoveNext
Loop
End If
Private Sub SetOEFields(OEFields As ACCPACXAPILib.xapiFields, Rs As ADODB.Recordset)
With Rs
For i = 0 To .Fields.count - 1
Select Case .Fields(i).Name
Case "rectype"
Case "ordnumber"
Case "orduniq"
Case Else
OEFields(.Fields(i).Name).Value = .Fields(i).Value
End Select
Next
End With
End Sub
Appriciate any help!