The goal here is to ensure that the sorted line items in Ms Access query attached in PDF format are picked exactly as they appear in a proper ascending order query so that the Json code send them to the virtual computer (invisible) exactly.
The start point is to count the item lines like below :
Now after counting the lines and pasting the total count into the control called Me.txtinternalaudit , then that control become part of the reference in the main code below together with invoice number being referenced as Me.txtJsonReceived. So in short the code below is concatenate the two references.
Me.txtinternalaudit is converted into itemCount , then into i , see below:
Main code below
Problems
The problem here is that, sometimes the code pick only one product throughout instead of item by item, sometimes it works okay it will pick specific item line by line as per representation by the MS Access query
Any idea how to correct the problem here?
The start point is to count the item lines like below :
Code:
'--- loop over all the items
itemCount = Me.txtinternalaudit
IIf(IsError(DCount("ItemesID","tblLineDetails","InvoiceID =" & [txtJsonReceived])),0,DCount("ItemesID","tblLineDetails","InvoiceID =" & [txtJsonReceived]))
Now after counting the lines and pasting the total count into the control called Me.txtinternalaudit , then that control become part of the reference in the main code below together with invoice number being referenced as Me.txtJsonReceived. So in short the code below is concatenate the two references.
Me.txtinternalaudit is converted into itemCount , then into i , see below:
Main code below
Code:
'--- loop over all the items
itemCount = Me.txtinternalaudit
For i = 1 To itemCount
Set item = New Dictionary
transactions.Add item
item.Add "itemSeq", i
item.Add "itemCd", DLookup("itemCd", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i))
item.Add "itemClsCd", DLookup("itemClsCd", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i))
item.Add "itemNm", DLookup("ProductName", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i))
item.Add "bcd", Null
item.Add "pkgUnitCd", "NT"
item.Add "pkg", 1
item.Add "qtyUnitCd", "U"
item.Add "qty", Nz(Round(DLookup("Qty", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "prc", Nz(Round(DLookup("BuyerSupply", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "splyAmt", Nz(Round(DLookup("SellerAmount", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "dcRt", Nz(Round(DLookup("Discount", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "dcAmt", Nz(Round(DLookup("Discamount", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "isrccCd", ""
item.Add "isrccNm", ""
item.Add "isrcRt", 0
item.Add "isrcAmt", 0
item.Add "vatCatCd", IIf((rs!TaxClassA.Value = ""), Null, rs!TaxClassA.Value)
item.Add "iplCatCd", Null
item.Add "tlCatCd", IIf((rs!AuditTourClass.Value <> ""), "TL", Null)
item.Add "exciseCatCd", Null
item.Add "vatTaxblAmt", Nz(Round(DLookup("Taxable", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "vatAmt", Nz(Round(DLookup("TaxAmount", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "exciseTaxblAmt", 0
item.Add "tlTaxblAmt", Nz(Round(DLookup("TLTaxable", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "iplTaxblAmt", 0
item.Add "iplAmt", 0
item.Add "tlAmt", Nz(Round(DLookup("TLLevyTax", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
item.Add "exciseTxAmt", 0
item.Add "totAmt", Nz(Round(DLookup("SellerAmount", "QryJson", "[InvoiceID] =" & Me.txtJsonReceived & "And ItemesID =" & CStr(i)), 4), 0)
Problems
The problem here is that, sometimes the code pick only one product throughout instead of item by item, sometimes it works okay it will pick specific item line by line as per representation by the MS Access query
Any idea how to correct the problem here?