Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : How do I create Multiple Invoices with Multiple Line Items using Access 2003 and QODBC 7Search Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Sample Scripts Forum

 New Topic 
 
 Post Reply 
[1]  
 How do I create Multiple Invoices with Multiple Line Items using Access 2003 and QODBC 7 
 Author   Message 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-11-30 07:05:38

I use MS Access 2003 to generate calculated totals for invoices that I need to post into QB. 

Using an Append Query I have been able to successully upload Invoices however all the line items show up on one invoice and the first customer appears in the invoice header info even though there are 4 customers total.

I have one Append Query that uploads the Line Items to the InvoiceLine Table and a second Append Query that uploads the Header information to the Invoice table (which I receive an error when I run it but the invoice turns up in QB anyway)  I'm using an Autonumber field to create the Invoice Number (RefNumber) - could the error be because they are different data types? 

What do I have to do to create multiple invoices with multiple line items?

Thank you!!!

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-11-30 14:11:40
Try looking at: Inserting invoice lines built from external data using MS Access and How do I create Invoices?  

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-01 02:01:49

The first article looks like the invoice is already assigned a TxnID in Quickbooks and the second option has the steps I followed to create the invoice but I still end up with only one invoice with all the line items in it.  My ListID fields are being taken directly from QuickBooks.

This is the SQL View of the 1st Access Query I created (to append line items)

INSERT INTO InvoiceLine ( TxnDate, CustomerRefListID, InvoiceLineItemRefListID, InvoiceLineDesc, InvoiceLineRate, InvoiceLineQuantity, FQSaveToCache, RefNumber )
SELECT [1-PostedInvoiceTotals].InvoiceDate, [1-PostedInvoiceTotals].CustomerRefListId, [1-PostedInvoiceTotals].InvoiceLineItemRefListID, [1-PostedInvoiceTotals].Name, [1-PostedInvoiceTotals].GrandTotal, 1 AS Qty, [1-PostedInvoiceTotals].FQSaveToCache, [1-PostedInvoiceHeaderTotals].InvoiceNumber
FROM [1-PostedInvoiceHeaderTotals] INNER JOIN (LocalCustomer INNER JOIN [1-PostedInvoiceTotals] ON LocalCustomer.ListID = [1-PostedInvoiceTotals].CustomerRefListId) ON [1-PostedInvoiceHeaderTotals].CustomerRefListId = [1-PostedInvoiceTotals].CustomerRefListId;

NOTE: CustomerRefListID should not be used here

This is the second Query (to post the Header Info:

INSERT INTO Invoice ( RefNumber, TxnDate, CustomerRefListID, CustomerRefFullName, ARAccountRefListID, BillAddressAddr1, BillAddressAddr2, BillAddressAddr3, BillAddressAddr4, BillAddressCity, BillAddressState, BillAddressPostalCode, ShipAddressAddr1, ShipAddressAddr2, ShipAddressAddr3, ShipAddressAddr4, ShipAddressCity, ShipAddressState, ShipAddressPostalCode )
SELECT [1-PostedInvoiceHeaderTotals].InvoiceNumber, [1-PostedInvoiceHeaderTotals].InvoiceDate, [1-PostedInvoiceHeaderTotals].CustomerRefListId, [1-PostedInvoiceHeaderTotals].CustomerRefFullName, [1-PostedInvoiceHeaderTotals].ARAccountRefListID, [1-PostedInvoiceHeaderTotals].BillAddressAddr1, [1-PostedInvoiceHeaderTotals].BillAddressAddr2, [1-PostedInvoiceHeaderTotals].BillAddressAddr3, [1-PostedInvoiceHeaderTotals].BillAddressAddr4, [1-PostedInvoiceHeaderTotals].BillAddressCity, [1-PostedInvoiceHeaderTotals].BillAddressState, [1-PostedInvoiceHeaderTotals].BillAddressPostalCode, [1-PostedInvoiceHeaderTotals].ShipAddressAddr1, [1-PostedInvoiceHeaderTotals].ShipAddressAddr2, [1-PostedInvoiceHeaderTotals].ShipAddressAddr3, [1-PostedInvoiceHeaderTotals].ShipAddressAddr4, [1-PostedInvoiceHeaderTotals].ShipAddressCity, [1-PostedInvoiceHeaderTotals].ShipAddressState, [1-PostedInvoiceHeaderTotals].ShipAddressPostalCode
FROM [1-PostedInvoiceHeaderTotals];

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-12-01 09:52:40
The data above indicates four invoices and not only one invoice with all the line items in it to me. 

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-01 10:16:22

Exactly!!  I WANT 4 invoices but in Quickbooks only 1 is created.  I'm trying to create Multiple Invoices with Multiple Line Items in each invoice.

Thank you for your time!

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-12-01 11:00:35
When we create an invoice with 3 lines we use 3 InvoiceLine INSERT commands (with the FQSaveToCache caching flag set true "1") followed by the Invoice table (header) insert, which is automatically designed to pull in all cached InvoiceLine records and save immediately. The Invoice table only shows one row for each invoice. To see all the invoice lines and all the lines in a invoice you need to be looking at the InvoiceLine table. 

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-01 11:12:51

When I look at the InvoiceLine Table, QuickBooks has applied the first customer number to all of the LineItems, even though there were 4 different customer numbers (that match customers in QB) in the data.  (I guess that's why I get only one invoice).  How do I tell it to create one invoice per customer? 

Thank you!

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-12-01 12:04:02

Simply do single line invoices as a single SQL INSERT with all the CUSTOMER detail and FQSaveToCache FALSE (0):-

INSERT INTO "InvoiceLine" ("CustomerRefListID", "ClassRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('470001-1071525403', '30000-933272658', 'QODBCClass2', '250000-933272656',
'Building permit Additional Room', 100.00000, 100.00, '20000-999022286', 0)

 

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-01 12:54:46

Will this give me one line per invoice (I'd end up with 29 invoices as opposed to 4?)  I'm not sure how to do single line inserts through an access query.

Thank you again for responding so quick - you know this is driving me crazy to figure out!!

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-12-01 15:06:37

You're nearly there. When FQSaveToCache is set false, or the header insert is executed (after lines have been cached), the cached lines of the invoice will get writtened.

The last example will give you 29 invoices, while the other time you got 1 invoice with four lines? So you need to check the FQSaveToCache logic in your append queries. For example for two invoices with two lines in each I do:

insert invoiceline FQSaveToCache 1  <<< Invoice 1 line 1
insert invoiceline FQSaveToCache 1 <<< Invoice 1 line 2
insert invoice  <<< header sets FQSaveToCache 0

Invoice 1 gets written to QuickBooks

insert invoiceline FQSaveToCache 1 <<< Invoice 2 line 1
insert invoiceline FQSaveToCache 1 <<< Invoice 2 line 2
insert invoice  <<< header sets FQSaveToCache 0

Invoice 2 gets written to QuickBooks

See: Using ClassRefListID when inserting invoice lines for a better example and how to add a line to an existing invoice.

 

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-02 00:56:47

So do I have to create these invoices one at a time?  Again, I'm not familiar with SQL but I don't think Access will allow me to append to more than one table at a time.   Thank you so much for your time. 

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-12-02 13:55:56

You can create any number of invoices you wish with a range of invoice lines using a sequence of SQL statements. You don't need to use the Invoice header and you can do your inserts just using the InvoiceLine table like this:

insert invoiceline FQSaveToCache 1 <<< Invoice 1 line 1
insert invoiceline FQSaveToCache 0 <<< Invoice 1 line 2

Invoice 1 gets written to QuickBooks

insert invoiceline FQSaveToCache 1 <<< Invoice 2 line 1
insert invoiceline FQSaveToCache 1 <<< Invoice 2 line 2
insert invoiceline FQSaveToCache 1 <<< Invoice 2 line 3
insert invoiceline FQSaveToCache 0 <<< Invoice 2 line 4

Invoice 2 gets written to QuickBooks

instead

 

  Top 
  Nicole 
  
 Group: Members 
 Posts: 20 
 Joined: 2006-05-04 
 Profile
 Posted : 2006-12-03 00:09:47

You are wonderful!!  Thank you so much!! 

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to