Webpage hyperlink not working

AlexD

Registered User.
Local time
Today, 17:15
Joined
Sep 20, 2002
Messages
35
I have a form whose source is a SQL Server linked table which consists of company details including a web address.

On the form is a control box that displays the web address - and I have turned this into a hyperlink so that the relevant company site can be opened - however it refuses to open the webpage from the hyperlink.

Does this have anything to do with the source being a linked SQL table? Can't change the field properties to 'Hyperlink' in SQL like you can in Access so I'm looking for a solution...any help appreciated.

cheers,

Alex
 
Are you using the Application.FollowHyperlink method? That is how you should be launching the web address to open Internet Explorer to that web address. Check the help files on how to use the FollowHyperlink method.
 
Thanks ... seems to be putting me on the right track.

I've put 'Application.FollowHyperlink Me![www]' behind the OnClick event of the text box (www is the name of the field with the web addresses)

Problem now is that when click on the address on the form, I'm getting a "runtime error 490 - cannot open the specified file".

Any ideas?
 
Here's another variation - instead of saving the field as a hyperlink change the field type to string and then use this code:
Code:
Dim strhyperlink as string
strhyperlink = me.NameOfYourField
Application.FollowHyperlink strhyperlink, , True, True

I usually bracket this type of statement with Docmd.Hourglass True and Docmd.Hourglass Flase so the the user knows the app is working as it usually takes a second or two for the db to open your broswer and subsequent web page...

HTH,
Kevin
 
Last edited:
Thanks Kevin, but it's still returning the same runtime error.

Running the pointer over the strhyperlink variable gives

strhyperlink = "www.nameofwebsite.com"

So it's picking up the site address, but it just can't open it.

Although it's works OK when you have an explicit hyperlink on the form, might it have something to do with a missing ActiveX control? :confused:
 
I was assuming that the web addresses were stored as text based on the orignal posting. Do not follow Me with a ! but the Me. is not needed for the code to "work".

Try this...

Code:
Application.FollowHyperlink [YourTextBoxNameHere]

This method does not use ActiveX.
 
Alex -

try gHudson's suggestion and if that still isn't getting it make sure you've changes the field to a string property (and not a hyperlink).

If you still have problems post back with the code you are using...

HTH,
Kev
 
OK chaps, still not working - maybe I've missed out something in my explanation that could be important.

The form is called 'Meeting List'

The text box on the form is called 'www' and the source field containing the web addresses is also called 'www' (the field source is from a query called 'Meeting List' based on fields from a linked SQL table).

I've changed the text box on the form to Hyperlink is 'No'.

I've changed the code behind the OnClick event based on your suggestions. At the moment the code is:

Private Sub WWW_Click()
Application.FollowHyperlink [www]
End Sub
 
Alex -

try changing the field in the table to text instead of hyperlink - then use the code I provided above. This will work for you - also - as an FYI there are alot of times where problems in code are the result of naming fields will access reservered keywords (such as naming a field in a table 'Date' where the word 'Date' is a reserved word in Access) so a part of the problem could be the field named 'www' although this is probably not the case. Also, also - when naming forms do not leave spaces in names as this can cause major problems when coding as well. Instead of calling the form 'Meeting List' try either 'MeetingList', 'Meeting_List', or the standardized naming convention for db/Access would be to use 'frmMailingList'... Not trying to lecture you just trying to give a few pointers to help you in the long run! :D

HTH,
Kev
 
Kevin,

Problem with changing the field type within the table is that it is a SQL table and does not have a hyperlink property... and it is already a text field anyway (or 'varchar' in SQL).

Changed the name of the field to 'Web', that didn't work either as you guessed.

Yeah, realise that spaces in names is not good practice, but have got away with it so far ;) .

As a test, and thinking that maybe the fact it was taking the source from a linked SQL table could be the problem, I set up a little test with a new form looking at a new ACCESS table with web addresses and put your code behind the OnClick - again the same problem. Which is leading me to think that my copy of Access is 'missing' something. Like an Active X control I mentioned earlier.
 
Alex -

I put together a sample db in A2000 (Actually in all three versions as I did it before I got your reply!). Open frmCustomer which should have some bogus data and click the button on the form - your web browser should open and display the address in the field "CustWebpage" from the form. I also used a SQL Server BE with this same example (used varchar as field type) and didn't have any problems with it... If what your experiencing is a result of a missing or broken reference you should be able to double check your references against the ones I use in the sample...

have a look and let me know if you need further help...

HTH,

Kev
 

Attachments

Kevin,

Got it to work...but not as you might have thought.

Rather naively, I thought that Access could resolve "www.whatever.com" - after all, the web browsers have no problem with this format, but after seeing your MSN.com example, it occured to me that maybe I might need http:// in front of any address to get it to work ... and it does.

After modifying your original code to :

Dim strHyperlink As String
strHyperlink = "http://" & Me.www
Application.FollowHyperlink strHyperlink, , True, True

Maybe though this is an Active X issue which means I have to do it this way?

But it's fine for now, although I'll have to make sure nobody enters http from now on for web addresses.

Anyway, many many thanks for all your help with this - very much appreciated.

cheers,

Alex
 
Alex -

Here is the code with a little modification. I set it up for you so that you can test to see if the user has entered the web address as "http://" or as "www". If they used the http then it doesn't alter the string - if they used www it adds the http:// to the string and then completes the followhyperlink action. Here's the code:

Code:
Dim strHyperlink As String

If Left(Me.www, 7) = "http://" Then
strHyperlink = Me.www
Else
strHyperlink = "http://" & Me.www
End If
Application.FollowHyperlink strHyperlink, , True, True
End Sub

Hope this helps!

Kev
 
Kevin,

The little 'If ... Left' code works perfectly!

Superb...thanks again.

Alex
 
Bit late on this thread but I suspect that the string you had in the hyperlink originally was fine. It looked correct didn't it. It just didn't work.

Some time try adding # to each end of tyhe string. Now interestingly you will not be able to see it one added but you my well find that the hyperlink works fine.

Its an interesting one that gave me a lot of grief a while ago. Let me know how you get on

Len B
 

Users who are viewing this thread

Back
Top Bottom