Solved How to use MS Access Messages Properly (1 Viewer)

nector

Member
Local time
Today, 19:54
Joined
Jan 21, 2020
Messages
405
I'm getting some input data from the internet based server in Json format like below if all is okay the message looks like below:

Code:
{
  "resultCd": "000",
  "resultMsg": "It is succeeded",
  "resultDt": "20240508194441",
  "data": {
    "rcptNo": 1235,
    "ReceitData": "DFR236599"
  
  }
}

Now I want to display the correct MS Access message that friendly if the above string with resultCd field = "000" , in short the message code should evaluate the above Json string as follows:

If message Json string is = "000" then
MsgBox Request.responsetext, tick, "Internal Audit Manager"
ElseIf Json string is <> "000" then
MsgBox Request.responsetext, vbCritical, "Internal Audit Manager"
End If
End If

If the tick does not exist in MS Access at least something friendly will do.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:54
Joined
Sep 12, 2006
Messages
15,755
this sort of thing?

there are lots of alternatives with a msgbox. you can add yes no buttons, and poll a reply result as well.

Code:
if yourstring="000" then
  msgbox "Success",vbok, 'Result"
else
  msgbox "Failure",vbexclamation, 'Result"
end if
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:54
Joined
Feb 19, 2002
Messages
43,774
If all you need out of the string is the code, then just use the mid function with Instr() to find the error code
 

nector

Member
Local time
Today, 19:54
Joined
Jan 21, 2020
Messages
405
Okay thank all I will use the information provided
 

cheekybuddha

AWF VIP
Local time
Today, 17:54
Joined
Jul 21, 2014
Messages
2,383
@tvanstiphout ,
The GetKeys() function in Jack's blog post seems truncated - do you have the rest of the code anywhere by chance?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:54
Joined
Oct 29, 2018
Messages
21,622
@tvanstiphout ,
The GetKeys() function in Jack's blog post seems truncated - do you have the rest of the code anywhere by chance?
Hope this helps...
Code:
Public Function GetKeys(ByVal JsonObject As Object) As String()
    Dim Length As Integer
    Dim KeysArray() As String
    Dim KeysObject As Object
    Dim Index As Integer
    Dim Key As Variant
 
    Set KeysObject = ScriptEngine.Run("getKeys", JsonObject)
    Length = GetProperty(KeysObject, "length")
    
    'adjusted by thedbguy@gmail.com
    '6/16/2020
    'handles empty array in json
    If Length > 0 Then
        ReDim KeysArray(Length - 1)
        Index = 0
        For Each Key In KeysObject
            KeysArray(Index) = Key
            Index = Index + 1
        Next
    Else
        ReDim KeysArray(0)
    End If
    GetKeys = KeysArray
End Function
 

jdraw

Super Moderator
Staff member
Local time
Today, 12:54
Joined
Jan 23, 2006
Messages
15,423
cheekybuddha/David,

Do you have a sample database using Dymeng/ Jack Leach's JSON Parser that you could share?
 

Users who are viewing this thread

Top Bottom