MDB to JSON converter [closed]
Here's a Microsoft Access database module function to export a table or query (passed as a string) and create a JSON date time stamped text file within the same folder as the Access database:
Function toJSON(PassTblQry)' EXPORT JSON FILE FROM TABLE OR QUERYDim mydb As Database, rs As RecordsetDim VarField(255), VarFieldType(255)Dim fld As DAO.Field, VarDat As StringSet db = CurrentDbfn = CurrentProject.Path & "\" & PassTblQry & " " & Format(Now(), "YYYY-MM-DD HHMM") & ".json" ' define export current folder query date/timeOpen fn For Output As #1 ' output to text fileRecs = DCount("*", PassTblQry) ' record countSet rs = db.OpenRecordset("Select * from [" & PassTblQry & "]")Nonulls = True ' set NoNulls = true to remove all null values within output ELSE set to falsefieldcount = 0' Save field count, fieldnames, and type into arrayFor Each fld In rs.Fields fieldcount = fieldcount + 1 VarField(fieldcount) = fld.Name 'Debug.Print VarField(fieldcount) VarFieldType(fieldcount) = "TEXT" Select Case fld.Type Case 4, 5, 6, 7 ' fieldtype 4=long, 5=Currency, 6=Single, 7-Double VarFieldType(fieldcount) = "NUMBER" End SelectNextSet fld = NothingPrint #1, "[" ' start JSON dataset' build JSON dataset from table/query data passedDo While Not rs.EOF Print #1, "{" ' START JSON record ' build JSON record from table/query record using fieldname and type arrays For looper = 1 To fieldcount VarFT = VarFieldType(looper) If VarFT = "NUMBER" Then QuoteID = "" ' No quote for numbers QuoteID = Chr(34) ' double quote for text If IsNull(rs(VarField(looper)).Value) Then ' deal with null values VarDat = "Null": QuoteID = "" ' no quote for nulls If Nonulls = True Then VarDat = "": QuoteID = Chr(34) ' null text to empty quotes If Nonulls = True And VarFT = "NUMBER" Then VarDat = "0": QuoteID = "" ' null number to zero without quotes Else VarDat = Trim(rs(VarField(looper)).Value) End If VarDat = Replace(VarDat, Chr(34), "'") ' replace double quote with single quote VarDat = Replace(VarDat, Chr(8), "") ' remove backspace VarDat = Replace(VarDat, Chr(10), "") ' remove line feed VarDat = Replace(VarDat, Chr(12), "") ' remove form feed VarDat = Replace(VarDat, Chr(13), "") ' remove carriage return VarDat = Replace(VarDat, Chr(9), " ") ' replace tab with spaces jsonRow = Chr(34) & VarField(looper) & Chr(34) & ":" & QuoteID & VarDat & QuoteID If looper < fieldcount Then jsonRow = jsonRow & "," ' add comma if not last field Print #1, Chr(9) & jsonRow Next looper Print #1, "}"; ' END JSON recordrs.MoveNextIf Not rs.EOF Then Print #1, "," ' add comma if not last record Else Print #1, ""End IfLoopPrint #1, "]" ' close JSON datasetClose #1End Function
For anyone else that needs an online Access database converter (mdb, accdb), I have built an online tool that converts almost all versions of Access databases to JSON, MySQL dump file or SQLite.
Here is the link: https://lytrax.io/blog/tools/access-converter
Any feedback, bug reports or suggestions are highly appreciated.
Yes there is a solution you can just take the mdb access database file to some one who has windows and use this program on the the file to extract or convert MS Access .mdb file to json file you can find the proram in this link and how to use it in this clip on youtube
https://www.youtube.com/watch?v=6adHmSfWs-othe program http://konbrand.com/DownLoads/