How to validate data in Ms Access Recordset using VBA
Dear All;
After getting more information here, I think there is need to validate the data before storing in a stagnant table in Ms access. I’m not sure about this topic frankly its new to me , I’m just try to see whether it will work.
I want to check whether Set rs = db.OpenRecordset("tblEfdRe ceipts") has data before proceeding to update , below is the full code:
I’m trying this code but I’m not sure of how do it correctly, the received data is never part of the live until checked.
Validation code require improvements
After getting more information here, I think there is need to validate the data before storing in a stagnant table in Ms access. I’m not sure about this topic frankly its new to me , I’m just try to see whether it will work.
I want to check whether Set rs = db.OpenRecordset("tblEfdRe
Set rs = db.OpenRecordset("tblEfdReceipts")
If lngStatus > 0 Then
ElseIf lngStatus < 0 Then
' Handle error.
On Error Resume Next
End If
' Process data.
Set JSONS = JsonConverter.ParseJson(strData)
Z = 2
For Each item In JSONS
With rs
.AddNew
rs![TPIN] = item("TPIN")
rs![TaxpayerName] = item("TaxpayerName")
rs![Address] = item("Address")
rs![ESDTime] = item("ESDTime")
rs![TerminalID] = item("TerminalID")
rs![InvoiceCode] = item("InvoiceCode")
rs![InvoiceNumber] = item("InvoiceCode")
rs![FiscalCode] = item("FiscalCode")
rs![TalkTime] = item("TalkTime")
rs![Operator] = item("Operator")
rs![Taxlabel] = item("TaxItems")("TaxLabel")
rs![CategoryName] = item("TaxItems")("CategoryName")
rs![Rate] = item("TaxItems")("Rate")
rs![TaxAmount] = item("TaxItems")("TaxAmount")
rs![VerificationUrl] = item("TaxItems")("VerificationUrl")
rs![INVID] = Me.InvoiceID
rs.Update
End With
Z = Z + 1
Next
rs.Close
Set rs = Nothing
Set db = Nothing
Set JSONS = Nothing
I’m trying this code but I’m not sure of how do it correctly, the received data is never part of the live until checked.
Validation code require improvements
Set rs = Me.Recordset.Clone
If Me.Recordset.RecordCount = 0 then 'checks for number of records
msgbox "There is no records"
End if
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The fastest way to check a LOCAL (not Linked) table for RecordCount is:
If CurrentDB.TableDefs("tblEf dReceipts" ).RecordCo unt = 0 Then 'whatever ....
If CurrentDB.TableDefs("tblEf
Open in new window