Re: MS-Access Send HTTP requests
- From: john@xxxxxxxxxxxxxxxxxx
- Date: Fri, 20 Feb 2009 05:53:10 -0800 (PST)
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
.
- Follow-Ups:
- Re: MS-Access Send HTTP requests
- From: Rick Brandt
- Re: MS-Access Send HTTP requests
- From: David W. Fenton
- Re: MS-Access Send HTTP requests
- References:
- MS-Access Send HTTP requests
- From: john
- Re: MS-Access Send HTTP requests
- From: Rick Brandt
- MS-Access Send HTTP requests
- Prev by Date: Access 2007 Issues
- Next by Date: Re: Adding up to 100%
- Previous by thread: Re: MS-Access Send HTTP requests
- Next by thread: Re: MS-Access Send HTTP requests
- Index(es):
Relevant Pages
|