Solved

HTTP post string to URL

Posted on 2011-09-06
6
389 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
Comment Utility
How does the URL looks like (endresult) with the parameters given?
0
 

Author Comment

by:Dalexan
Comment Utility
I don't have an example. This is the first it's being used.
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
This worked excellent, thanks for your quick response and posting the full sample code on how to get this working...Excellent....
0
 
LVL 74

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now