I'm getting an error on the counter section whenever i run the code below , where is the problem:
Error in a picture
The Json part is coming okay see the dump
Code:
Public Sub CmdSendingBomFineshedProd_Click()
On Error Resume Next
Dim Cancel As Integer
If IsNull(Me.CboIssue) Then
Beep
MsgBox "Please Select the Product name you want to transfer data to smart invoice", vbInformation, "Wrong data"
Cancel = True
Exit Sub
End If
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Company As New Dictionary
Dim strData As String
Dim n As Long
Dim Json As Object
Dim data As New Dictionary
Dim transactions As Collection
Dim itemCount As Long
Dim i As Long
Dim item As New Dictionary
Dim prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("QryBOMFinishedProduct")
For Each prm In qdf.Parameters
prm = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset(dbOpenSnapshot, dbSeeChanges)
Set qdf = Nothing
rs.MoveFirst
Do While Not rs.EOF
Set data = New Dictionary
Set transactions = New Collection
Set Company = New Dictionary
Company.Add "tpin", Forms!frmLogin!txtsuptpin.Value
Company.Add "bhfId", Forms!frmLogin!txtbhfid.Value
Company.Add "sarNo", rs!SarNumber.Value
Company.Add "orgSarNo", 0
Company.Add "regTyCd", rs!regTyCd.Value
Company.Add "sarTyCd", rs!sarTyCd.Value
Company.Add "custTpin", "1000000000"
Company.Add "custNm", "Walk In Customer"
Company.Add "custBhfId", rs!custbhfld.Value
Company.Add "ocrnDt", Format((rs!IssueDate.Value), "yyyymmdd")
Company.Add "totItemCnt", Me.txtinternalaudit
Company.Add "totTaxblAmt", Round(DSum("taxblAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
Company.Add "totTaxAmt", Round(DSum("taxAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
Company.Add "totAmt", Round(DSum("totAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
Company.Add "remark", "Okay"
Company.Add "regrNm", Forms!frmLogin!txtpersoning.Value
Company.Add "regrId", Forms!frmLogin!txtpersoning.Value
Company.Add "modrNm", Forms!frmLogin!txtpersoning.Value
Company.Add "modrId", Forms!frmLogin!txtpersoning.Value
Company.Add "itemList", transactions
'--- loop over all the items
itemCount = Me.txtExternalAudit
For i = 1 To itemCount
Set item = New Dictionary
transactions.Add item
item.Add "itemSeq", i
item.Add "itemCd", DLookup("itemCd", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "itemClsCd", DLookup("itemClsCd", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "itemNm", DLookup("ProductName", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "pkgUnitCd", DLookup("pkgUnitCd", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "qtyUnitCd", DLookup("qtyUnitCd", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "pkg", DLookup("Qty", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "qty", DLookup("Qty", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "totDcAmt", 0
item.Add "prc", Round(DLookup("dftPrc", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
item.Add "splyAmt", Round(DLookup("dftPrc", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
item.Add "taxblAmt", Round(DLookup("taxblAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
item.Add "vatCatCd", DLookup("vatCatCd", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue)
item.Add "taxAmt", Round(DLookup("taxAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
item.Add "totAmt", Round(DLookup("totAmt", "QryBOMFinishedProduct", "[SlipID] =" & Me.CboIssue), 4)
Error in a picture
The Json part is coming okay see the dump
Code:
{
"tpin": "1000000453",
"bhfId": "000",
"sarNo": 1511,
"orgSarNo": 0,
"regTyCd": "M",
"sarTyCd": "05",
"custTpin": "1000000000",
"custNm": "Walk In Customer",
"custBhfId": "000",
"ocrnDt": "20240908",
"totItemCnt": 2,
"totTaxblAmt": 1487.069,
"totTaxAmt": 237.931,
"totAmt": 1725,
"remark": "Okay",
"regrNm": "Admin Manager",
"regrId": "Admin Manager",
"modrNm": "Admin Manager",
"modrId": "Admin Manager",
"itemList": [
{
"itemSeq": 1,
"itemCd": "ZM2EAEA000000",
"itemClsCd": "23181510",
"itemNm": "SPECIAL PIE",
"pkgUnitCd": "EA",
"qtyUnitCd": "EA",
"pkg": 23,
"qty": 23,
"totDcAmt": 0,
"prc": 75,
"splyAmt": 75,
"taxblAmt": 1487.069,
"vatCatCd": "A",
"taxAmt": 237.931,
"totAmt": 1725
}
]
}