Hello everyone I hope some can help me. I want to parse a json text in VBA and store it in an MS Access table and it almost work.
I use a libraries the GitHub one to parse but only problem when I want to import the data to my table I get a data type conversion error
. I don't know how to fix it. Below is my code:
Public Sub exportCCProductidInfo()
Dim coll As Object
'Dim json As New ClsJsonParser
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim reader As String
Dim ccproductid As Variant
Set db = CurrentDb
Set rs = db.OpenRecordset("CcProductid_details", dbOpenDynaset, dbSeeChanges)
Set coll = JsonConverter.ParseJson(getTerminalsByCcproduits())
For Each ccproductid In coll
rs.AddNew
rs!cc_product_id = ccproductid("cc_product_id") 'this is where i have the problem
rs!Connected = ccproductid("connected")
rs!interface = ccproductid("interface")
rs!registered = ccproductid("registered")
rs!Type = ccproductid("type")
rs.Update
Next
End Sub
getTerminalsByCcproduits()
is another function I created and which returns me this result
[
{
"cc_product_id":"0195d-2b0d6-1524c-05508-1",
"connected":"4",
"interface":"None",
"registered":"4",
"type":"Internal Voice Mail Unit"
}
]
The problem is that instead of having
rs!cc_product_id = ccproductid("cc_product_id")
I have rs!cc_product_id=5
or else and ccproductid("cc_product_id")= "0195d-2b0d6-1524c-05508-1"
So please, how do I fix this data error?