Solved

HTTP post string to URL

Posted on 2011-09-06
6
394 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 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Industry Leaders: 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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

724 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