Object variable not set

tried username "xxx" and "arnelgp" did get the expected results.

using username "xxx", credit: 14137
using username "arnelgp", credit: 10
Code:
Public Function CheckCredits()
    Dim oHttp As Object
    Dim SMSCredits
    Dim strUrl, strUsername, strPassword, strMessage, strMobileNumber  As String
    Set oHttp = CreateObject("Microsoft.XMLHTTP")
    
    strUsername = "kxxx"
    strPassword = "kxxx"
    'strUsername = "arnelgp"
    'strPassword = "arnelgp"
    
    strUrl = "http://www.mymobileapi.com/api5/http5.aspx?Type=credits&username=" & strUsername & "&password=" & strPassword
    
    oHttp.Open "POST", strUrl, False
    oHttp.Send
    
    Dim sResult As String
    Dim nPos As Long
    Dim strResult As String
    sResult = oHttp.ResponseText
    nPos = InStr(sResult, "<result>")
    If nPos <> 0 Then
        strResult = Mid(sResult, nPos + Len("<result>"))
        strResult = Left(strResult, InStr(strResult, "</result>") - 1)
    End If
    If strResult = "True" Then
        nPos = InStr(sResult, "<credits>")
        strResult = Mid(sResult, nPos + Len("<credits>"))
        strResult = Left(strResult, InStr(strResult, "</credits>") - 1)
        
        SMSCredits = CDbl(strResult)
        
    Else
        MsgBox "A SMS account has not been created for you. Kindly notify us about this", vbCritical, "Notice"
    End If
    Set oHttp = Nothing
    CheckCredits = SMSCredits
End Function
 
Good morning
My results are still the same as in post #20

What version of Access did you test it on?

Thanks
 
im using A2013, but it doesnt matter since we are only using Microsoft.XMLHTTP function.
try capturing this using Msgbox:

Msgbox oHTTP.ResponseText

show us the result, if nothing shows up then there must be something wrong (maybe firewall problem).
 
Wow - you have just hit the nail on the head!!
It turned out to be a firewall type of problem.
The A2013 machine I'm testing on sits behind a proxy.
I honestly had no idea that it would have an effect on the routine.
I feel a bit like a cake now since there was not really a problem with the code.
Really sorry about that
 

Users who are viewing this thread

Back
Top Bottom