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
|
|
Creating a multiple line invoice using MS Access |
Author |
Message |
SWT |
|
Group | : Members |
Posts | : 20 |
Joined | : 2006-11-09 |
|
Profile |
|
Posted : 2007-08-01 08:50:34 |
I am trying to create a multiple line invoice by using MS Access and an append query (into the invoiceline table). When I append my data the results in QB is 5 invoices for one customer with the same refnumber. How can I get all 5 lines into one invoice easily. I prefer not to use the method where you would create the first line in one invoice first, then get the id number from that and insert additional lines later. |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-08-01 09:27:12 |
You will need to execute the inserts within the one sub procedure. Here's an example:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim insertStr As String
insertStr = "INSERT INTO InvoiceLine (" & _ "CustomerRefListID, CustomerRefFullName, " & _ "RefNumber, InvoiceLineItemRefListID, " & _ "InvoiceLineDesc, InvoiceLineRate, InvoiceLineAmount, " & _ "InvoiceLineQuantity, InvoiceLineTaxCodeRefListID, FQSaveToCache" & _ ") VALUES (" & _ FormatStr(CustomerID) & "," & FormatStr(CustomerName) & "," & _ FormatStr(RefNumber) & "," & FormatStr(ItemListID) & "," & _ FormatStr("Desc") & "," & "1.0000," & "120.00," & "1.00," & _ FormatStr(GSTString) & ",1" & _ ")"
Try ODBCExecute(insertStr) Catch Ex As Exception MessageBox.Show(Ex.Message) End Try
insertStr = "INSERT INTO Invoice (" & _ "CustomerRefListID, CustomerRefFullName, RefNumber, BillAddressAddr1, " & _ "BillAddressAddr2, Memo" & _ ") VALUES (" & _ FormatStr(CustomerID) & "," & FormatStr(CustomerName) & "," & FormatStr(RefNumber) & "," & _ FormatStr("Bill1") & "," & FormatStr("Bill2") & "," & FormatStr("Memo") & _ ")" Try ODBCExecute(insertStr) Catch Ex As Exception MessageBox.Show(ex.Message) End Try
End Sub
Private Function FormatStr(ByVal aStr As String) As String Return "'" & aStr.Replace("'", "''") & "'" End Function |
|
|
|
SWT |
|
Group | : Members |
Posts | : 20 |
Joined | : 2006-11-09 |
|
Profile |
|
Posted : 2007-08-02 02:16:12 |
2 questions about this sub procedure method: Can I use it with MS Access, and can I use it with more than one multiple invoice at a time? (I am currently pulling data out of one system and want to insert multiple invoices each day into the back end of QB. There could be from 10 to 30 invoices entered with multiple lines each day.)
not being well versed in SQL, the code above does not mean much to me. I was hoping there would be some field in the invoiceline table that could be manipulated with my append query in MS Access, is this not the case? |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-08-02 08:15:58 |
If you perfer to Append Queries you would need to use the method where you would create the first line in one invoice first, then get the TNXID from that and insert additional lines later. |
|
|
|
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-10-14 08:02:59 |
About your function:
Private Function FormatStr(ByVal aStr As String) As String Return "'" & aStr.Replace("'", "''") & "'" End Function
I think it should be like this in access in order to work properly
Private Function FormatStr(ByVal aStr As String) As String FormatStr="'" & Replace(aStr,"'", "''") & "'" End Function
I have me sql preconfigured with the outer apostrophes so I am thinking i only need:
Private Function FormatStr(ByVal aStr As String) As String FormatStr=Replace(aStr,"'", "''")
End Function
(As in a product like Cilantro-Bunched (30's)
I had went thru QB and eliminate naming using apostrophies, but I realize I cannot insure that users will not use them so perhaps I should implement this? If so do I have it right in the 3rd function example?
|
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-10-14 21:42:35 |
All the function is trying to really do is to surround the variable in single quotes, so Tom becomes 'Tom' |
|
|
|
|
Posted : 2007-11-15 04:36:27 |
Function ToSQL(Value, sType) on error resume next Dim Param : Param = Value if Param = "" then ToSQL = "Null" else if lcase(sType) = "number" then ToSQL = replace(cstr(Param), ",", "") elseif lcase(sType) = "text" then ToSQL = "'" & Replace(Param, "'", "''") & "'" elseif lcase(sType) = "date" then ToSQL = "#" & Param & "#" end if end if end function |
|
|
|
|