Proposed Answer Access to search web page?

  • Saturday, April 14, 2012 1:20 AM
     
     

    Can my text box be used as a hyperlink to seach for something on the net?..Thanks for any Help................Bob

    The web page is : http://www.nzracing.co.nz/Meetings/HorseSearch.aspx

    Page Script for horse search from web page below 

    cmdHorseSearch_onclick()"/Meetings/HorseSearch.aspx#search";function cmdReportSearch_onclick()document.frmHead.action = "/Meetings/HorseSearch.aspx#search";

    document.frmHead.action =

    function

All Replies

  • Saturday, April 14, 2012 8:59 PM
     
     

    Can my text box be used as a hyperlink to seach for something on the net?..Thanks for any Help................Bob

    The web page is : http://www.nzracing.co.nz/Meetings/HorseSearch.aspx

    Page Script for horse search from web page below 

    cmdHorseSearch_onclick()"/Meetings/HorseSearch.aspx#search";function cmdReportSearch_onclick()document.frmHead.action = "/Meetings/HorseSearch.aspx#search";

    document.frmHead.action =

    function

    It looks like the search is performed via code-behind for the specific page. Think of the code-behind as the equivalent of a VBA module behind a Form or Report in Access. For security reasons, ASP.NET is specifically designed so that you can only interact with pages like this from an ASP.NET generated page. If the page had been designed to accept a query string (ex: http://lmgtfy.com/?q=irs+2012+taxes&id=654136 ) you could create code that automatically creates the necessary URL that would return the search results when the page is opened.

    You might be able to create code that opens the page, fills in the values into the elements and the submits the form, however I do not know how you would automate that via Access VBA. Its a simple thing via JavaScript/VBScript, but both would require that you script to the actual ASP.NET page.


    David H

  • Saturday, April 14, 2012 9:27 PM
     
     
    I can write VBA code that will retrieve the data.  But David has a good point.  If David can write the Java code and put it into a webpage.  I can run the code from a macro.

    jdweng

  • Saturday, April 14, 2012 9:43 PM
     
     

    Thanks Guys if my textbox content tbHorsename could go into the Web page search box then his data would show on the web page!

    Regards Bob Vance Thanks for any help

  • Monday, April 16, 2012 1:27 AM
     
     
    I can write VBA code that will retrieve the data.  But David has a good point.  If David can write the Java code and put it into a webpage.  I can run the code from a macro.

    jdweng


    The issue isn't writing the JavaScript (not Java btw). I only mentioned JavaScript and VBScript to confirm that the elements can be manipulated via the DOM (Document Object Model). The issue is accessing the DOB via VBA. Conceptually its the same as automating one Office app from another. However, I have no idea if its possible with a browser.

    David H

  • Monday, April 16, 2012 8:48 AM
     
     Proposed Answer Has Code

    I did a request a few years ago to run the Google Translation from VBA.  what we ended up doing was to create a very simple webpage with two boxes (input and out put translation), a button to start the translation, and some java to activate the google utility.  We stored the webpage to a html file on a PC.

    The VBA code read the source text from a workbook.  Then opened a webbrowser, put the text into the source box in the webpage and press the control button which ran the java code.  Finally the VBA code put the translated text from the webpage back into the excel workbook.

    We didn't know how to directly run java code from excel or VBA code.  So we let the webpage run the java code for us.  We have the same issue here.  How do you run Java code from Access VBA?  I proposing lettting a webpage run the java!!!

    Here is the webpage we used.  We stored it as a file called

    c:\temp\translate.html.  The we opened it in a browser using the following URL : file:\\c:\temp\translate.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Google Translate API</title>
    </head>
    <body>
    <form name="f" id="f" action="#" onsubmit="translate(); return false;">
    <textarea name="foreign_text" id="foreign_text" rows="4"
    cols="60"></textarea>
    <br />
    <br />
    <input type="submit" id="submit_button" value="Translate into English"
    onfocus="this.blur();" />
    <br />
    <br />
    <textarea name="translation" id="translation" rows="4" cols="60"
    onfocus="this.select();" readonly="true"></textarea></form>
    <br />
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("language", "1");
    function translate() {var
    originaltext=document.forms["f"].foreign_text.value;
    google.language.translate(originaltext, "", "en", function(result) {
    document.forms["f"].translation.value = (result.error)?("Error:
    "+result.error.message):result.translation; }); }
    </script>
    </body>
    </html>

  • Monday, April 16, 2012 1:42 PM
     
     

    What version of Access are you using?  It seems to me that with Access 2007 or 2010, you should be able to use VBA to manipulate a Web Browser control to do your search.  I haven't done that myself, though I've seen convincing demonstrations.  If you're using Access 2003 or earlier, you could create an MSXML object for the purpose.

    Using the web browser control, the search results would be returned as a web page, which you could either display in the control or parse to get information out and do something with it.

    Hmm, looking at the page, you'll probably need to manipulate an MSXML object to push the search value into the page and click the button.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html


  • Monday, April 16, 2012 2:25 PM
     
     

    I cna easily write the code to do the search except for the problem that you have to maually set controls on a form on the webpage before doing the search.  I think the user wants to do the search automatic from a text box.  The webpage java script takes inputs from the userform on the webpage.   I can write code to set the controls on the userform, but that requires bring up a webbrowser which is slow.   I don't know java well enough to be able to bypass the forms input and use an MSXLM object.  My though is to create a new webpage with just a small amount of java.

    Dirk: I'm not sure if you arre correct in saying that you can't use tthe MSXML object in versions of Access after 2003.  I think the object can be added by browsing for the object in the system32 folder.  The object just isn't built into Access.  The MSXLM object is part of a windows dll.


    jdweng

  • Monday, April 16, 2012 2:43 PM
     
     

    Dirk: I'm not sure if you arre correct in saying that you can't use tthe MSXML object in versions of Access after 2003. 

    I didn't say that, and didn't mean even to imply it, though I can see why you might interpret what I wrote that way.  I just meant that it's an option for earlier versions of Access that don't have the web browser control (although there is a more cumbersome ActiveX version of the WBC available in earlier versions).

    I have used the MSXML object to extract info from web pages, as well as automating Internet Explorer by manipulating its object model via DOM.  This sort of thing is very doable.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html