We are planning to open a supermarket in a busy place now the tax authority requires us to be sending any prices changes to their office each time we make any changes The reason for this is to ensure that they have record also
The prices changes are sent to the tax authority by using an API shown below which is fine and works ok no issues at all
Problem area
(1) To send the data someone has to select the product in a combo box one by one, the reason for using the combo box is because the API allows one transaction at a time NOT bulk
Question
Is there a way to send the same transaction one after another until all the transactions finishes in the combo box. Here we are trying to eliminate the requirement of stationing someone on the computer to be selecting transaction one by one in the combo box and then keep on clicking send command per each transaction selected.
Is there a way to use VBA to send all the transaction in the combo box by one click instead of asking one person to be selecting one item, second etc and then click send, Imagin you have 1000 items in the combo box selecting one by one surely, it's a pain.
Combo Box
API that sends data to the tax authority
The prices changes are sent to the tax authority by using an API shown below which is fine and works ok no issues at all
Problem area
(1) To send the data someone has to select the product in a combo box one by one, the reason for using the combo box is because the API allows one transaction at a time NOT bulk
Question
Is there a way to send the same transaction one after another until all the transactions finishes in the combo box. Here we are trying to eliminate the requirement of stationing someone on the computer to be selecting transaction one by one in the combo box and then keep on clicking send command per each transaction selected.
Is there a way to use VBA to send all the transaction in the combo box by one click instead of asking one person to be selecting one item, second etc and then click send, Imagin you have 1000 items in the combo box selecting one by one surely, it's a pain.
Combo Box
Code:
SELECT
tblProducts.ProductID,
tblProducts.ProductName,
tblProducts.itemCd,
tblProducts.Status
FROM
tblProducts
WHERE
(((tblProducts.Status) IS NULL))
ORDER BY
tblProducts.ProductName;
API that sends data to the tax authority
Code:
Private Sub CmdProductsDetails_Click()
Dim Cancel As Integer
If IsNull(Me.CboProcductDetals) 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 prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("QrySmartInvoiceProductsDetails")
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 Company = New Dictionary
Company.Add "tpin", Forms!FrmLogin!txtsuptpin.Value
Company.Add "bhfId", Forms!FrmLogin!txtbhfid.Value
Company.Add "itemCd", rs!itemCd.Value
Company.Add "itemClsCd", rs!itemClsCd.Value
Company.Add "itemTyCd", rs!itemTyCd.Value
Company.Add "itemNm", rs!ProductName.Value
Company.Add "itemStdNm", rs!ProductName.Value
Company.Add "orgnNatCd", rs!orgnNatCd.Value
Company.Add "pkgUnitCd", rs!pkgUnitCd.Value
Company.Add "qtyUnitCd", rs!qtyUnitCd.Value
Company.Add "vatCatCd", rs!vatCatCd.Value
Company.Add "iplCatCd", "IPL1"
Company.Add "tlCatCd", rs!taxAmtTl.Value
Company.Add "exciseCatCd", "ECM"
Company.Add "btchNo", Null
Company.Add "bcd", Null
Company.Add "dftPrc", rs!dftPrc.Value
Company.Add "addInfo", Null
Company.Add "sftyQty", Null
Company.Add "isrcAplcbYn", "N"
Company.Add "useYn", "Y"
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
strData = JsonConverter.ConvertToJson(Company, Whitespace:=3)
rs.MoveNext
Loop
Dim Request As Object
Dim stUrl As String
Dim Response As String
Dim requestBody As String
stUrl = "http://localhost:8080/XXXXXXXXXXXXXXXXX"
Set Request = CreateObject("MSXML2.XMLHTTP")
requestBody = strData
With Request
.Open "POST", stUrl, False
.setRequestHeader "Content-type", "application/json"
.Send requestBody
Response = .ResponseText
End With
If Request.Status = 200 Then
MsgBox Request.ResponseText, vbInformation, "Internal Audit Manager"
'Cleanup:
rs.Close
Set db = Nothing
Set rs = Nothing
Set qdf = Nothing
Set prm = Nothing
Set Json = Nothing
Set Company = Nothing
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryCloseProductssentEIS"
MsgBox "Products Or Service Journal Posting successful", vbInformation, "Please Proceed"
End If
Me.CboProcductDetals = ""
Me.CboProcductDetals.Requery
End Sub