Re: MS-Access Send HTTP requests



On Feb 20, 3:00 pm, Rick Brandt <rickbran...@xxxxxxxxxxx> wrote:
On Fri, 20 Feb 2009 04:50:51 -0800, john wrote:
I am trying to use MSXML.dll to send HTTPRequests from within Access

When I compile my code I get “User-defined type not defined” for the
line of code below

    Dim httpObj As MSXML.XMLHTTPRequest

Any ideas on how to properly define the type?

Your syntax is correct for early binding which would require that you set
a reference to the MSXML.dll in Tools - References.  Have you done that?

Better is to NOT do that and switch your syntax to late binding.  That
does not require a reference and will make your code independent of the
MSXML library version that is installed.  Since there are about a half
dozen versions that is a much more robust solution.

For late binding you dim your variables as "Object".

Dim httpObj As Object
Set httpObj = New("XMLHTTPRequest")

I am making an educated guess on that last line as I currently don't have
any of my sample code to look at, but it is along those lines and a web
search should easily turn up the exact syntax.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Late binding is a very good idea and I have used it extensively to
Access to Outlook and Excel.

I replaced what you suggested and it does not compile.All the sample
codes which I found on the Web, related to C.

I include the subroutine where I include my code. If you have the
correct syntax, it would be greatly appreciated.

Initially I tried Early binding but was unable to locate the correct
reference in Access. Do you know which reference should be included?

Thanks,
John



Private Function SendSmsViaWebHttpRequest(suniqueid As String, smob As
String, smsg As String, sheader As String, sdatetimesend As String,
slogin As String, spwd As String) As String

On Error GoTo ErrorHandler

Dim httpObj As MSXML.XMLHTTPRequest

Dim X As Long

Dim Body As String

Dim surl As String



SendSmsViaWebHttpRequest = ""



Body = ""



surl = Replace(DFN_SEND_MSG_URL, "%MSG%", smsg)

surl = Replace(surl, "%ID%", suniqueid)

surl = Replace(surl, "%MOB%", smob)

surl = Replace(surl, "%HEADER%", sheader)

surl = Replace(surl, "%DATETIME%", sdatetimesend)

surl = Replace(surl, "%LOGIN%", slogin)

surl = Replace(surl, "%PWD%", spwd)



Set httpObj = New MSXML.XMLHTTPRequest



Call httpObj.open("POST", surl, False)



Call httpObj.setRequestHeader("Content-type", "application/x-www-
form-urlencoded")



Call httpObj.send(Body)



SendSmsViaWebHttpRequest = httpObj.responseText



Set httpObj = Nothing



Exit Function

ErrorHandler:

MsgBox "SendSmsViaWebHttpRequest : " & Err.Description & " - " &
Err.Number

End Function


.



Relevant Pages

  • Re: Move through DataGridView records
    ... In your code example for me, I can't figure how to reference ... You were asking why I was using 'Dim Source as Data View' in my code.... ... then bind the Binding Source to your DataSource, ... ByVal stringValue as String) ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: Complex Specified Information - Pitman Formula
    ... Therefore a significant match between a reference and a test ... string is good evidence of non-random production. ... and there are no finite algorithms to compute their digits. ... probabilities of the different symbols the information source can produce. ...
    (talk.origins)
  • Re: String Reference Type
    ... All unary and binary operators have predefined implementations that are ... Therefore its always allocated in the heap and a variable of string ... As with all classes in this case y and x both reference the same String ... language depandant matter as below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Abstract class variables question
    ... But as I think you've seen elsewhere in this thread, a value type can exist inside a class and in that case the value type is stored in the heap with the rest of the class instance. ... But as far as the "faster" goes, yes...to some extent value types have less overhead than reference types, and so can perform better in certain cases. ... Well, that would be true for a string object too, if there was any way to actually change a string. ... Seriously though, it is practically always the case that when you are writing an assignment to a reference, you're replacing the reference held by the variable. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Measurement of pitch
    ... as the method used by the Pythagoreans. ... of these reference units in the quantity to be measured. ... vibrating string seems as good as anything. ... The string or pendulum in question could no doubt be specified exactly, ...
    (sci.physics)