Coincidentally I had tried just what you said. ie switch off the "Optimize after insert or update" It did not help the speed any. Check the following code lines and see if you see something that I am missing that would speed things up.
Repeat step one and step 2 for each invoice line
Step one
Private Sub InsertInvoiceLineUsingCustID() Dim qInsertInvoiceLineUsingCustID_SQL As String Me.lblMessageBox.Caption = "Writing " & OrderDetails(lineitem, 5) & " " & OrderDetails(lineitem, 3) & " to QuickBooks" ' Inserts into the invoice line table 'now write the first line item to the invoice line table 'see qInsertInvoiceLineUsingCustID in query container for editing qInsertInvoiceLineUsingCustID_SQL = "INSERT INTO InvoiceLine(CustomerRefFullName," _ & "InvoiceLineItemRefFullName, InvoiceLineDesc, Invoice" _ & "LineQuantity, InvoiceLineRate, FQSaveToCache )" _ & "Values('" & OrderDetails(lineitem, 2) & "', '" & OrderDetails(lineitem, 3) & "', '" & OrderDetails(lineitem, 4) & "', '" _ & OrderDetails(lineitem, 5) & "', '" & OrderDetails(lineitem, 6) & "',1)"
DoCmd.RunSQL qInsertInvoiceLineUsingCustID_SQL <--Is there a faster / better way to do this? Should I use the customer ID instead of the name?? (Maybe I need the jumpin)
End Sub
Step 2
Private Sub FindNewestLineItemTxnIDByCustomer() Dim qFindNewestLineItemTxnIDByCustomerSQL As String Dim y As Integer 'now find out what TxnID, ainvoicelineitemreflistid, and RefNum that quickbooks 'assigned to the first invoiceline by using the customer name and looking for last txn. qFindNewestLineItemTxnIDByCustomerSQL = "SELECT TOP 1 InvoiceLineTxnLineID from InvoiceLine " _ & "UNOPTIMIZED where CustomerRefFullName=(('" & OrderDetails(lineitem, 2) & "'))" _ & "ORDER BY TimeCreated DESC;"
Set rec = db.OpenRecordset(qFindNewestLineItemTxnIDByCustomerSQL) rec.MoveFirst OrderDetails(lineitem, 7) = rec(0) 'the InvoiceLineTxnID rec.Close aQBRefNum = RefNum End Sub
Step 3
Private Sub InsertHeaderIntoInvoiceTable() Dim InsertHeaderSQL As String Me.lblMessageBox.Caption = "Creating Invoice Header" InsertHeaderSQL = "INSERT INTO " & "Invoice" & " (" & "CustomerRefListID" _ & "," & " CustomerRefFullName" & ", " & "TxnDate" & ", " _ & "PONumber" & ", " & "ShipDate" & ", " & "CustomFieldOther" & ", " & "CustomFieldDeliveryTime" & ", " _ & "CustomFieldFOBorDEL" _ & ") VALUES ('" & aCustID & "','" & aCustFullName _ & "','" & aTxnDate & "','" & aPONumber & "','" & aShipDate & "','" & aDelDate & "','" & aDelTime & "','" & aFOBorDEL & "')" DoCmd.RunSQL InsertHeaderSQL <--Is there a faster / better way to do this? End Sub
Another thing that is weird (to me at least), is that I decided to make 'copies' of the customer list and the item list within the Access application, this way I don't need to query the tables from QODBC. So I provided the users with a cmd button that they can click to update the copies if they have changed the customers or items in quickbooks. This utilizes a make table query and is surprisingly pretty fast compared to writing the invoice lines.
Using QODBC to write an invoice to quick books for 4 sales lineitems should not take 5 minutes should it??? If it does I may have to find an alternate solution. |