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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Invoice from Order and specificing Invoice Number

Status
Not open for further replies.

DanFuhrmann

Programmer
Sep 22, 2008
7
I am writing an interface to insert orders and create invoices for ACCPAC Advantage 5.5A. Im using the COM objects.

In the past we insert the new order, change the invoice number, and then create the invoice.

Here's the code where I find the order, process any order header updats, and create the invoice

Code:
'Open all the views
dbACCPAC.OpenView "OE0520", vwOH
dbACCPAC.OpenView "OE0500", vwOD
dbACCPAC.OpenView "OE0680", vwSN
dbACCPAC.OpenView "OE0180", vwCmts
dbACCPAC.OpenView "OE0740", vwPS
dbACCPAC.OpenView "OE0522", vwOF
dbACCPAC.OpenView "OE0526", vwOFQ
dbACCPAC.OpenView "OE0501", vwODOF
dbACCPAC.OpenView "OE0502", vwKD
dbACCPAC.OpenView "OE0503", vwKS
dbACCPAC.OpenView "OE0504", vwBOM
 
'Call Compose method on all the views
vwOH.Compose Array(vwOD, vwSN, vwCmts, vwPS, vwOFQ, vwOF)
vwOD.Compose Array(vwOH, vwODOF, vwKS, vwKD) 'change vwBOM to vwKS
vwSN.Compose Array(vwOH, vwOD)
vwCmts.Compose Array(vwOH, vwOD)
vwPS.Compose Array(vwOH)
vwOF.Compose Array(vwOH)
vwOFQ.Compose Array(vwOH)
vwODOF.Compose Array(vwOD)
vwKD.Compose Array(vwOD, vwBOM) 'changed vwKS to vwBOM
vwKS.Compose Array(vwOD) 'changed vwKD to vwOD
vwBOM.Compose Array(vwKD) 'changed vwOD to vwKD

'Search for Order
vwOH.Order = 1
vwOH.Browse "ORDNUMBER=""" & vstrOrderNumber & """", True
  
.
. Update header code here
. 

'Process Header Update
vwOH.Process

'Update invoice number
vwOH.Fields("INVNUMBER").Value = rstInvHeader("InvoiceNumber")
'Tell it to produce the invoice
vwOH.Fields("INVPRODUCE").Value = 1

'Do the create        
vwOH.Update

It fails when I try to set the INVNUMBER saying its a readonly field. This worked in prior versions.

If I dont try and assign the ivoice number it creates an invoice with the next number. Anyone know how I can update that invoice number now?

 
I think you need to change the order:
Code:
vwOH.Fields("INVPRODUCE").Value = 1
vwOH.Fields("INVNUMBER").Value = rstInvHeader("InvoiceNumber")
 
That does stop the error. But now it does not create an invoice. Do I need to somehow generate a shipping record first?
 
Thanks for the help. Do you know is there a manual for the ACCPAC COM? I am going off some previous code. It looks like it was not necessary to do the shipping step in the past. So I am flying blind. It looked logically from what happened when the first order posted and the shipping record auto genereated that one was necessary. But I dont know how to genereate it in my code. I appreciate the help!

 
No manual - just the school of hard knocks. However, most of the time if you record a macro of the process in the new version then you can track down the changes like you've experience above.
 
Step 1 is always record a macro.
Most of the time there are some subtle changes with new versions that throw out macros or programs written for previous versions.
 
Thanks! That is all helpfull. The macro is a great suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top