Custom Hyperlink Button In a Form

dcfi6052

Registered User.
Local time
Today, 03:51
Joined
Jan 25, 2012
Messages
34
I am relatively new with access, but do have some experience with it. My weakest skill would have to be the Coding. I do have to give some info on my database before asking my question, so please have patience :)

I am currently making a DVD database that is quite large and rapidly coming more complex as I have new ideas to improve functionality. Right now I am trying to help myself with developing a slightly faster method of filling out data for movies. My database is not an easy list of just the names of films, but also has fields like genre, actors, lengths, etc.

I use internet movie database a lot to help me fill out missing data, but am trying to have a hyperlink button take me to the website. I currently have my movie list set up as a vertical split form with the hyperlink button next to each movie title. As of right now the button does function and it does bring me to the website. I used this as my code (take out the "_"):

Private Sub Command25_Click()

Application.FollowHyperlink _

"h_t_t_p_://w_w_w._i_m_d_b_.c_o_m"

End Sub


I wanted to take it a step further but have no idea how to code it. I want the hyperlink button to not just take me to the standard homepage of the site, but to the specific movie on the site. If I search "avatar" on their site I get a web address of "h_t_t_p://w_w_w.imdb._c_om/find?q=avatar&s=all" (Take out the "_"). So If I replaced "Avatar" with lets say "MovieName" and then defined "MovieName" in access as whatever is typed in the movie name field, would that not then open the webpage for each individual movie?:confused:

In my head I would think that would work, but don't have the knowledge to code for it. Does anyone have any ideas??

Thanks in advance! I have access 2010 by the way.
 
I think this would be a neat trick to learn. I've never attempted it, but here is something that may help.
 
So If I replaced "Avatar" with lets say "MovieName" and then defined "MovieName" in access as whatever is typed in the movie name field, would that not then open the webpage for each individual movie?:confused:
One of the parameters of Application.FollowHyperlink is to open the webpage in a new window. It's the second parameter.
 
I'm not sure how that helps the op, vbaInet. He's trying to query a website from Access.
 
I'm answering that specific question I quoted. VBA doesn't control the URL so amending the URL in the web browser will have to be handled by the user. If the OP passes the right string to the FollowHyperlink command with the open in new window param, it will open the search result in a new window.

Manually perform a search on the site.
Examine the URL for the search tags.
Copy the URL and costruct your search string before passing it to FollowHyperlink
 
So we have no alternative but to reverse engineer how strings are used by the website then?
 
There's the DOM option but you will need to understand DOM and HTML in order to do it.
 
Hmm...I played with HTML once and hated it. I've never heard of this DOM you speak of though. Do you have any good links?
 
DOM = Document Object Model.

I think there's some sample code from ajetrumpet in the Sample Code section of the forum or somewhere in the parent section.
 
Yes, I just looked it up. Here is an example. The last sub at the bottom shows how to use IE (eewww) and search wikipedia for "Document Object Modeling".

edit- And here is a list of IE events and methods.
 
Last edited:
Thanks for all the help so far guys!

I tried a few different things and I think I'm on the right track (could be completely wrong :o).

So I have My "open IMBD" button and my code is as followed (not including the "_"):

Private Sub OpenIMDB_Click()

strURL = "ht_tp://im_db.co_m/find?q= " & [FilmNameBox] & ""

Application.FollowHyperlink strURL

End Sub


So this code works but it also doesn't.

If my [FilmNameBox]= Avatar the website opens to an address of:

"http_://w_ww.imd_b.com/find?q=%2520%2520Avatar" (Not including the ("_")

So where is the "%2520" coming from??:confused:

In the search box on the webpage it displays "%20%20Avatar"
So again we have a bunch of %20 popping up and I don't know why:confused:

Any Ideas?
 
That just represents a space. You will need to do your own research on HTML encoding. To be honest, you need to understand some HTML too.
 
I do have HTML experience although it has been years since I last did it. This database I have is the only one I am doing/ will do and I'm not interested in reading up on all the VBA functions and punctuation (Basic and advanced) in order to solve 2 issues I am having with my database. These issues are just to have the database run smoother and create a more user friendly environment. So If I can't figure it out then it's not a big deal, but it would still be nice to have functional and it would be nice to receive some more guidance. And I do appreciate all the help I have been given from everybody thus far! :)I see this custom hyperlink as being advanced (Not just for me but others too) and I just need to know if I'm on the right track or if I'm way off.


So you say the numbers represents a space eh? So is there anyway to get rid of these spaces by altering my current code? Or would I have to start from scratch and use a different function??
 
FollowHyperlink is really not that advanced. It's just a simple function where you fill in the parameters and it does the job for you. This is how your FollowHyperlink code could look like:
Code:
Application.FollowHyperlink "http://www.imdb.com/find?q=" & Replace(Me.FilmNameBox, " ", "%20") & "&s=All", , True
If you want anything more sophisticated than this you need to look at the links provided.
 
That looks great! I'll have to try it later when I get home. I'll let you know.

Thanks vbaInet!
 
The code works great! just what I needed! Thanks so much to everyone for their help and patience. You all rock! :cool:
 

Users who are viewing this thread

Back
Top Bottom