I'm trying to develop a progress meter to help users have an idea of how long their report or open record set is taking running, this way users will have full ideas of what is going on in the system rather than just waiting.
The small, attached database has a VBA module below working in conjunction with a small form called frprogress:
(1) I have attached code to the report and running simultaneously which I think is not correct, the idea here is that the progress meter should start when the report is opening and automatically close when the report is visible.
(2) If the above works well I want to attach it also to the code below, but I'm not sure where exactly to put it?????????/
The small, attached database has a VBA module below working in conjunction with a small form called frprogress:
Code:
Private Sub CmdReports_Click()
Dim Cancel As Integer
Const REPORTCANCELLED = 2501
On Error Resume Next
DoCmd.OpenReport "rptPurchasesDetails", acViewPreview & ProgressMtr
DoCmd.Close acForm, "frmProgress"
Select Case Err.Number
Case 0
' no error
Case REPORTCANCELLED
' anticipated error, so ignore
Case Else
' unknown error, so inform user
MsgBox Err.Number & Err.Description, vbExclamation, "Error"
End Select
End Sub
(1) I have attached code to the report and running simultaneously which I think is not correct, the idea here is that the progress meter should start when the report is opening and automatically close when the report is visible.
(2) If the above works well I want to attach it also to the code below, but I'm not sure where exactly to put it?????????/
Code:
Public Sub CmdCwrite_Click()
Call CmdTotalClasses_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Dim Company As New Dictionary
Dim strData As String
Dim Json As Object
Dim data As New Dictionary
Dim transactions As Collection
Dim itemCount As Long
Dim i As Long
Dim n As Integer
Dim z As Integer
Dim item As New Dictionary
Dim items As New Collection
Dim prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("QryJson")
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", rs!suptpin.Value
Company.Add "bhfId", rs!bhfId.Value
Company.Add "invcNo", rs!InvoiceID.Value
Company.Add "orgInvcNo", Nz(rs!OrignalInvoiceNumber.Value, 0)
Company.Add "custTpin", rs!TPIN.Value
Company.Add "prcOrdCd", IIf((rs!NewprcOrdCd.Value = "0"), 0, "")
Company.Add "custNm", rs!Company.Value
Company.Add "salesTyCd", rs!SalesType.Value
Company.Add "rcptTyCd", rs!DocCodes.Value
Company.Add "pmtTyCd", rs!PaymentIDs.Value
Company.Add "salesSttsCd", "02"
Company.Add "cfmDt", rs!ActualDate.Value
Company.Add "salesDt", Format((rs!ShipDate), "yyyymmdd")
Company.Add "stockRlsDt", IIf(Len(rs!stockreleasing), rs!stockreleasing, Null)
Company.Add "cnclReqDt", Null
Company.Add "cnclDt", Null
Company.Add "rfdDt", Null
Company.Add "rfdRsnCd", rs!rfdRsnCding.Value
Company.Add "totItemCnt", Me.txtinternalaudit
Company.Add "taxblAmtA", Round(Nz(Me.txtclassA, 0), 2)
Company.Add "taxblAmtB", Round(Nz(Me.txtclassB, 0), 2)
Company.Add "taxblAmtC1", Round(Nz(Me.txtclassC1, 0), 2)
Company.Add "taxblAmtC2", Round(Nz(Me.txtclassC2, 0), 2)
Company.Add "taxblAmtC3", Round(Nz(Me.txtclassC3, 0), 2)
Company.Add "taxblAmtD", Round(Nz(Me.txtclassD, 0), 2)
Company.Add "taxblAmtRvat", 0
Company.Add "taxblAmtE", 0
Company.Add "taxblAmtF", 0
Company.Add "taxblAmtIpl1", 0
Company.Add "taxblAmtIpl2", 0
Company.Add "taxblAmtTl", 0
Company.Add "taxblAmtEcm", 0
Company.Add "taxblAmtExeeg", 0
Company.Add "taxblAmtTot", 0
Company.Add "taxRtA", Nz((rs!Tax.Value) * 100, 0)
Company.Add "taxRtB", Nz((rs!Tax.Value) * 100, 0)
Company.Add "taxRtC1", 0
Company.Add "taxRtC2", 0
Company.Add "taxRtC3", 0
Company.Add "taxRtD", 0
Company.Add "taxRtE", 0
Company.Add "taxRtF", 0
Company.Add "taxRtIpl1", 0
Company.Add "taxRtIpl2", 0
Company.Add "taxRtTl", 0
Company.Add "taxRtEcm", 0
Company.Add "taxRtExeeg", 0
Company.Add "taxRtTot", 0
Company.Add "taxRtRvat", 0
Company.Add "taxAmtA", Round(Nz(Me.txtttaxclassA, 0), 2)
Company.Add "taxAmtB", Round(Nz(Me.txtttaxclassb, 0), 2)
Company.Add "taxAmtC1", 0
Company.Add "taxAmtC2", 0
Company.Add "taxAmtC3", 0
Company.Add "taxAmtD", 0
Company.Add "taxAmtE", 0
Company.Add "taxAmtF", 0
Company.Add "taxAmtIpl1", 0
Company.Add "taxAmtIpl2", 0
Company.Add "taxAmtTl", 0
Company.Add "taxAmtEcm", 0
Company.Add "taxAmtExeeg", 0
Company.Add "taxAmtTot", 0
Company.Add "taxAmtRvat", 0
Company.Add "totTaxblAmt", Round(Nz(Me.txttotaxableAB, 0), 2)
Company.Add "totTaxAmt", Round(Nz(Me.txttotaltaxAll, 0), 2)
Company.Add "totAmt", Round(Nz(Me.txtGrandtotal, 0), 2)
Company.Add "prchrAcptcYn", rs!prchrAcptcYn.Value
Company.Add "remark", rs!TheNotes.Value
Company.Add "regrId", "11999"
Company.Add "regrNm", rs!CreatedBy.Value
Company.Add "modrId", "45678"
Company.Add "modrNm", rs!CreatedBy.Value
Company.Add "receipt", data
data.Add "custTpin", rs!TPIN.Value
data.Add "custMblNo", rs!Phone.Value
data.Add "rptNo", 0
data.Add "trdeNm", rs!Company.Value
data.Add "adrs", rs!Address.Value
data.Add "topMsg", ""
data.Add "btmMsg", "Thank you for choosing us"
data.Add "prchrAcptcYn", rs!prchrAcptcYn.Value
Company.Add "itemList", transactions
'--- 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", rs!itemCd.Value
item.Add "itemClsCd", rs!itemClsCd.Value
item.Add "itemNm", rs!ProductName.Value
item.Add "bcd", Null
item.Add "pkgUnitCd", "NT"
item.Add "pkg", 1
item.Add "qtyUnitCd", "U"
item.Add "qty", rs!Qty.Value
item.Add "prc", rs!UnitPrice.Value
item.Add "splyAmt", rs!UnitPrice.Value
item.Add "dcRt", 0
item.Add "dcAmt", 0
item.Add "isrccCd", Null
item.Add "isrccNm", Null
item.Add "isrcRt", Null
item.Add "isrcAmt", Null
item.Add "vatCatCd", rs!TaxClassA.Value
item.Add "iplCatCd", "IPL1"
item.Add "tlCatCd", "TL"
item.Add "exciseCatCd", "EXEEG"
item.Add "taxblAmt", Round(rs!SupplierAmount.Value, 2)
item.Add "vatAmt", Round(rs!FinalTax.Value, 2)
item.Add "iplAmt", Null
item.Add "tlAmt", Null
item.Add "exciseAmt", Null
item.Add "totAmt", Round(rs!TotalAmount.Value, 2)
strData = JsonConverter.ConvertToJson(Company, Whitespace:=3)
rs.MoveNext
Next
Loop
Dim Request As Object
Dim stUrl As String
Dim Response As String
Dim requestBody As String
Dim Details As Variant
stUrl = "http://localhost:9090/churchelder/paster/senior/local"
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"
Set rst = db.OpenRecordset("select vsdcRcptPbctDate,rcptNo,intrlData,rcptSign FROM [tblCustomerInvoice] WHERE [InvoiceID] = " & Me.txtJsonReceived, dbOpenDynaset)
Set Json = JsonConverter.ParseJson(Request.responsetext)
'Process data.
On Error Resume Next
rst.Edit
rst![rcptNo] = Json("data")("rcptNo")
rst![intrlData] = Json("data")("intrlData")
rst![rcptSign] = Json("data")("rcptSign")
rst![vsdcRcptPbctDate] = Json("data")("vsdcRcptPbctDate")
rst.Update
On Error Resume Next
ElseIf (Request.Status <> 200) Then
MsgBox Request.responsetext, vbCritical, "Internal Audit Manager"
rs.Close
rst.Close
Set rst = Nothing
Set rs = Nothing
Set qdf = Nothing
Set prm = Nothing
Set Json = Nothing
End If
End Sub