Missing Values in The Code in Ms Access
Sorry all the out there I have made a mistake to close the earlier question on the ms access vba /Json code below:
The value are missing I did not notice that my appology
Private Sub CmdSales_Click()
Const SQL_SELECT As String = "SELECT * FROM Qry1;"
Dim coll As New Collection
Dim dict As Scripting.Dictionary
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Set coll = New Collection
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL_SELECT, dbOpenSnapshot)
If Not rs.BOF And Not rs.EOF Then
Do While Not rs.EOF
Set dict = New Scripting.Dictionary
For Each fld In rs.Fields
dict.Add fld.Name, rs.Fields(fld.Name)
Next fld
coll.Add dict
rs.MoveNext
Loop
End If
rs.Close
Set fld = Nothing
Set rs = Nothing
Set db = Nothing
Set dict = Nothing
MsgBox JsonConverter.ConvertToJson(coll, Whitespace:=3)
Set coll = Nothing
End Sub
The value are missing I did not notice that my appology
How does the Json convert work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My recommendation is to pass the (populated) recordset into a conversion routine. Recordsets are, basically, a collection of dictionaries (if you squint at them).
ASKER
Dear Ste5an
Thank you so much this is un believable it is done for good! what a great job!
Thank you so much once more!
Regards
Chris
Thank you so much this is un believable it is done for good! what a great job!
Thank you so much once more!
Regards
Chris
Dictionary stores Key and Value.
In the key you save the FieldName and in the Value the Value of the Field....
Collection will only save 1 single value....(it also has an index but is not easy to refer to it)
I think your code can use Dictionary...SO start slowly...create a Dictionary ....insert a couple of Keys/Values and feed to the Json Converter...check if it works OK....just check the output string....make a quick and dirty example...don't feed your complete recordsource....just a small test
Points gone from previous question ... :(