How can I send a database query via HTTP from VBA code?

Posted on 2006-05-10
Last Modified: 2006-11-18
I need to use HTTP to send the following query from Access VBA code and retrieve the XML response.  Notice that the PHP script is performing the function of an ASP script.

(Note: the site name above is just a sample.  It does not really exist)

When I send this via a browser, the PHP script queries the database and sends the answer back in XML.  I need to see some sample VBA code that can send the query via HTTP and retrieve the response WITHOUT the browser.

This is extremely urgent. Please help!

Question by:liberty1947
    1 Comment
    LVL 25

    Accepted Solution

    Here you go:

    Function HTTPGet(url As String) As String

        Dim xmlhttp
        Dim retval As String
        Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
        xmlhttp.Open "GET", url, False
        retval = xmlhttp.responseText
        Set xmlhttp = Nothing
        HTTPGet = retval

    End Function

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    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…
    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…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now