Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    sephiroth2906 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    73

    Click on a word or phrase to go to a website and enter that word or phrase in search

    Howdy all!

    I have a database I am working on that I hope to incorporate some kind of code or commands that will allow me to click on a database entry, and cause that entry to open a specific webpage, then put the entry I clicked on in a search field there.



    I am wondering if this is possible, and where to start if it is.

    Any assistance is appreciated. Thanks for taking the time to read this!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sephiroth2906 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    73
    Actually, I am less worried about interacting with the website than I am figuring out how to cause the click on the word or phrase to cause a function of some sort to be carried out.

    Instead if a search field, I can pass the information into a spot in a URL and pass that URL to a web browser instead of filling a search field. I don't know how to make a field "clickable" or how to put the word clicked into the URL or how to pass the URL to the browser.

    I guess I don't know much more than what I want to accomplish. Again, I appreciate any guidance!

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    see this linkfor more info

    also research webbrowser control and application.followHyperlink

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    And http://allenbrowne.com/func-GoHyperlink.html

    Are you using a form for data entry?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    sephiroth2906 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    73
    I am, yes.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Did either of the links give you ideas?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    Just my opinion, I don't think this has anything to do with FollowHyperlink.

    You can automate Internet Explorer - that's the common approach. You can use

    Code:
    Dim IE as object
    set IE = createobject("internetexplorer.application")
    IE.visible=true 'easier for debugging and eyeballing what is going on
    IE.Navigate "some URL"
    After that point, you will need to right-click on the page and View Source to see what you are up against. There is no one size fits all answer. If you see button IDs and textbox IDs, you might get lucky, then you can use things like:

    Code:
    IE.Document.GetElementyByID("id number").Value = "something"
    IE.Document.Forms("formName").submit
    OR
    Code:
    IE.Document.getelementbyid("button1").Click
    As you can see, a significant amount of legwork on your part will be required. In many cases you will need
    Code:
    'Do Until ie.Busy = False
    DoEvents
    'Loop
    in between lines of code to "wait" for IE to be ready.

    It will be very likely much less than 100% reliable, hit & miss, and totally fail if/when the webpage programmer changes the slightest detail.

    If the page depends on calling javascript functions rather than button click events and such, you will need yet a slightly different approach for the Wait concept, since IE won't be busy.....But a java script function could very likely still be busy.

    See if that gets you anywhere and post back if you get stuck. I will try to help.

    The best advice is, "don't do/rely on it: Get an API from the website owner instead".

  9. #9
    sephiroth2906 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    73
    I am actually less worried now about how to pass the information to the browser, since instead of sending the information to an API, I just want to open a webpage. My previous idea sounds much more difficult. It might help to explain what my proof of concept is.

    I created a database as a proof of concept. In this database, I put in some Magic the Gathering cards. What I would like to do , from the results of a query returning several different cards, is click on the name of one of the cards. When I click on it, I want it to do a couple of things.

    The first is to take the name of the card and put it in a string, which happens to be a URL. An example of this would be

    http://magiccards.info/query?q=badlands&v=card&s=cname

    I would like to have the area in red be where the card name goes. So, if I clicked on a card called "arrest" then the string would look like this:


    http://magiccards.info/query?q=arrest&v=card&s=cname

    Then I need to instruct access to open a browser with that URL.

    The links provided did not really give me what I was looking for, but that is likely my fault for not providing clear information as to my intent. Does this change anything.

    As always, I truly appreciate your time.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    The Allen Browne links explain the structure of a hyperlink string as well as demonstrate code that constructs a hyperlink. You can use code to build the URL you desire and then use either FollowHyperlink or Allen's GoHyperlink procedure to open web page.

    I tried the links you posted but I am blocked and can't open.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    Thanks, based on that information, just go with the first part of my post - which automates opening IE, and navigating to a URL.

    Of course you will need to do some basic string funtions in VBA to build the URL, right?

    Something like:

    Code:
    Dim strURL as String
    Dim IE as object
    set IE = createobject("internetexplorer.application")
    IE.visible=true 'easier for debugging and eyeballing what is going on
    strURL = http://magiccards.info/query?q= & Me.Textboxname.Value & "&v=card&s=cname"
    IE.Navigate strURL
    OK, no matter what I do, this forum prevents me from typing what I intended. It keeps changing the text to a darn URL =

    basically, you need to put quotes around the part of what I posted that starts with http and ends with = (equals sign)

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Yes, preventing the string converting to URL in post is tricky. Go to Advanced post editor. Below post window is an option for turning off ''Automatically parse links in text". Click this first then type the string. If it formats as url after typing a space, then Backspace until it goes away then press Enter. Something about a space after the url.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    Quote Originally Posted by June7 View Post
    Yes, preventing the string converting to URL in post is tricky. Go to Advanced post editor. Below post window is an option for turning off ''Automatically parse links in text". Click this first then type the string. If it formats as url after typing a space, then Backspace until it goes away then press Enter. Something about a space after the url.
    Got it - thanks!

    (Up to now I had only tried Remove Formatting and Remove Link). (and a few well-placed scowls at my monitor)

  14. #14
    sephiroth2906 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    73
    Boy am I sadly out of practice. I need to spend more time coding.

    So, if I create a datasheet form from a query or table, with the name of the card set as a hyperlink, this code:

    Private Sub txtName_Click()

    Dim strURL As String
    Dim IE As Object
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True 'easier for debugging and eyeballing what is going on
    strURL = "http://magiccards.info/query?q=" & Me.txtName.Value & "&v=card&s=cname"
    IE.Navigate strURL

    End Sub

    After naming the field Name "txtName" works like a charm. Now I need to figure out how to make a search, which has always baffled me to one extent or another. Once again, thanks for the help! Not only does this work, but I understand WHY it works, which is always a good thing

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    For a control named "cmdLinkMe" I would just place this in the click event....

    Me.cmdLinkMe.HyperlinkAddress = "http://Google.com"

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 04-14-2013, 01:33 PM
  2. Call word object and import word fields
    By silverspr in forum Programming
    Replies: 3
    Last Post: 12-10-2012, 11:32 PM
  3. Replies: 1
    Last Post: 11-18-2012, 10:41 PM
  4. Click a Button to Run Word Mail Merge...
    By nchesebro in forum Programming
    Replies: 6
    Last Post: 03-09-2011, 01:41 PM
  5. Subsets (not sure if that is the correct phrase)
    By LifeIsBeautiful in forum Queries
    Replies: 1
    Last Post: 10-07-2010, 11:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums