Hi
Surprised I'm experiencing MS Access hanging after using the record set continuously every after-11th Call on the record set, I strongly believe probably I'm not cleaning up the record set properly, see the code below:
Surprised I'm experiencing MS Access hanging after using the record set continuously every after-11th Call on the record set, I strongly believe probably I'm not cleaning up the record set properly, see the code below:
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", vbCritical, "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", rs!TPIN.Value
Company.Add "bhfId", rs!bhfId.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", "A"
Company.Add "iplCatCd", "IPL1"
Company.Add "tlCatCd", "TL"
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", rs!regrNm.Value
Company.Add "regrId", rs!regrId.Value
Company.Add "modrNm", rs!modrNm.Value
Company.Add "modrId", rs!modrId.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://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
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, vbCritical, "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"
Me.CboProcductDetals = ""
Me.CboProcductDetals.Requery
Me.CboProcductDetals.SetFocus
End If
End Sub