Solved

HTTP post string to URL

Posted on 2011-09-06
6
391 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access query expression 6 21
Exporting Access Tables as CSV 3 24
Access Importing Table Query With Specific Timestamp Daily 2 12
Modify report 8 6
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

773 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