Creating A/R Invoice (Error -5002)
Hi all,
Does anyone know why this code would throw the "- 5002 Invalid total [OINV.Address]" error? Any ideas?
Here is my code, and datas:
[code]Dim ReturnValue As Long
Dim ErrCode As Long
Dim ErrMsg$ = ""
Dim vInvoice As SAPbobsCOM.Documents
Dim iLine As Long
vInvoice = vCompany.GetBusinessObject(MyObjectType)
'MyObjectType = 13
vInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
vInvoice.CardCode = MyCardCode$
'MyCardCode = Is an existing BP's code
vInvoice.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vInvoice.DocDueDate = MyDocDueDate
'MyDocDueDate = #5/9/2006#
vInvoice.DocDate = MyDocDate
'MyDocDate = #5/9/2006#
vInvoice.TaxDate = MyDocDate
'MyDocDate = #5/9/2006#
vInvoice.VatDate = MyDocDate
'MyDocDate = #5/9/2006#
For iLine = 1 To MyLineNr
If iLine > 1 Then
vInvoice.Lines.Add()
End If
vInvoice.Lines.ItemCode = MyItemCode$(iLine - 1)
'MyItemCode = Is an existing item code
vInvoice.Lines.Quantity = MyQuatity(iLine - 1)
'MyQuantity 1 = 1
'MyQuantity 2 = 1
vInvoice.Lines.Price = MyPrice(iLine - 1)
'MyPrice 1 = -100
'MyPrice 2 = 300
vInvoice.Lines.VatGroup = MyVatGroup$(iLine - 1)
'MyVatGroup = Is an existing VAT group
Next iLine
ReturnValue = vInvoice.Add
[/code]
Thanks the help.