?
Solved

HTTP post string to URL

Posted on 2011-09-06
6
Medium Priority
?
402 Views
Last Modified: 2012-05-12
I need to post data from a table in access to a URL for each record. Please post full sample code on how to accomplish this from within an access.mdb via VBA

single table contains all the data needed for the post url's parameters.

URL: http://www.marketmytinkie.com/4321/receive/post.php

Parameters to post to the URL:
firstname,lastname,address,product,ordernumber
0
Comment
Question by:Dalexan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:danishani
ID: 36492731
How does the URL looks like (endresult) with the parameters given?
0
 

Author Comment

by:Dalexan
ID: 36492739
I don't have an example. This is the first it's being used.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 36493003
You should be able to do something like this. Add a reference to "Microsoft WinHTTP Services, version 5.1" and then use the following code:

Function PostData(firstName As String, lastName As String, address As String, product As String, orderNum As String) As String
    Dim req As New WinHttp.WinHttpRequest
    
    With req
        .Open "POST", "http://192.168.56.101/index.php?"
        .SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
        .Send "firstname=" & firstName & "&lastname=" & lastName & "&address=" & address & "&product=" & product & "&ordernumber=" & orderNum
        PostData = .ResponseText
    End With

    Set req = Nothing
    
End Function

Open in new window


Usage would be along these lines:
Sub test()
    resultingHTML = PostData("john", "doe", "123 Main St., Anytown, USA", "widgets", "12345")
    
    MsgBox resultingHTML
End Sub

Open in new window

0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36493008
P.S.

Don't forget to change the URL (the 2nd parameter in line 5). I forgot to change it from my test address  : \
0
 

Author Closing Comment

by:Dalexan
ID: 36516936
This worked excellent, thanks for your quick response and posting the full sample code on how to get this working...Excellent....
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36518083
NP. Glad to help  = )
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question