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
Solved

HTTP post string to URL

Posted on 2011-09-06
6
392 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
  • 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 500 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

828 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