Form Method=Post

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to post data to a URL from an Access form, similar to an HTML
<form method=post action=...> ?

Thanks!
 
WCR said:
Is there a way to post data to a URL from an Access form, similar to
an HTML <form method=post action=...> ?

Thanks!

Dim oHttpPost As Object
Set oHttpPost = CreateObject("Microsoft.XMLHTTP")
oHttpPost.Open "POST", "YourURL", False
oHttpPost.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
oHttpPost.Send ("YourData")
 
When I try this, it seems to think a while, but doesn't do anything. I don't
get any error messages. Any thoughts? Do you need to force a browser window
to open? I am using Access 2000 - is that a problem? What is the format of
"YourData"? "param=value"? Also, what is the "False" in the open command?
 
WCR said:
When I try this, it seems to think a while, but doesn't do anything.
I don't get any error messages. Any thoughts? Do you need to force
a browser window to open? I am using Access 2000 - is that a
problem? What is the format of "YourData"? "param=value"? Also,
what is the "False" in the open command?

It was a simplified example. The assumption was that you would know how to
encode the data that is placed into the Send command such that the web
service on the other end would be able to process it. To simulate the
submission from a web form you would normally use the format
"param1=value1&param2=value2..." Obviously you would need to have
additional code that takes your Access form's data and places it into a
variable in this format. You also need additional code to process the
response from the HTTPRequest to get any return values and to see if the
request succeeded.
 
I can handle putting the parameter string together, but I'm not sure I
understand what to do with the response. With the web form, you hit the
submit button and the form posts the data to the server, the server
calculates the response, and displays it in the explorer window. That's what
I'm trying to accomplish here. How do you send the response to a web
browser? I apologize if I am missing something basic here, I am new to this.
Your help is greatly appreciated.
 
WCR said:
I can handle putting the parameter string together, but I'm not sure I
understand what to do with the response. With the web form, you hit
the submit button and the form posts the data to the server, the
server calculates the response, and displays it in the explorer
window. That's what I'm trying to accomplish here. How do you send
the response to a web browser? I apologize if I am missing something
basic here, I am new to this. Your help is greatly appreciated.

In the case of a web form you fill out and press [ SUBMIT ] that web page is
"posting" that data to some service that does the processing and display of
another page that you are describing. By doing the POST from Access you are
bypassing the first form altogether and sending the data directly to the web
resource for processing. That web resource then sends back a stream of HTML
(typically) as the response so your Access code has to be able to take that
response and do something with it.

If you write it to a file with an HTM extension then you can use Shell or
FollowHyperlink against that file and it will be displayed in your default
web browser. An alternative would be to parse the stream in your code, pull
what you need out of it and display something inside of Access itself.

When I do this stuff I am sending XML data back and forth so I parse the XML
response and stuff the data into tables or display it on a form.
 
I have figured out how to capture the server's response using
oHttpPost.responseText. The response is in html format. How do I display
the page in internet explorer instead of capturing the response as a text
string?
 
WCR said:
I have figured out how to capture the server's response using
oHttpPost.responseText. The response is in html format. How do I
display the page in internet explorer instead of capturing the
response as a text string?

As I stated previously, you would write the response stream to a file that you
create with the Open statement. If you name that file with an HTM file
extension then you can just use Shell or FollowHyperlink to view it in a
browser.
 
Back
Top