Handling website Hyperlinks on form ('Address' is blank) (1 Viewer)

RSIboy

Registered User.
Local time
Today, 02:46
Joined
Jul 1, 2004
Messages
32
Hi

Apologies if this has been covered before, but a quick search didn’t bring up any solutions….

I have a customer table with name/address etc, together with a url field. Currently this is set to a datatype of Hyperlink. I then have a customer form that displays the underlying records, and would like to be able to click on the displayed hyperlink, and be taken to the website.

Currently, the url appears on the form but in the majority of cases clicking the link doesn't do anything. I've discovered the problem is apparent when I right-click the field and choose Hyperlink > Edit Hyperlink. In most cases the "Text to display:" is www.abc.com but the "Address:" is blank.

If I manually overtype the text in the url field as "www.abc.com", it then works (and unsuprisingly shows up in the "Address:" box when I edit the Hyperlink)!

Many of the url fields have been imported from text spreadsheets, but I was under the impression that the Access datatype of 'Hyperlink' would force the contents of the field to work as http://"FIELDCONTENTS" when clicked. Is there some VBA/query I could run to fix all the records so that they contain a hyperlink with both 'text to display' *and* the 'address'?

Could anyone shed any light on this issue? Any comments much appreciated...

Cheers
 

Simon_MT

Registered User.
Local time
Today, 02:46
Joined
Feb 26, 2007
Messages
2,176
You could remove the hyperlink format and just use the url and construct a function:
Code:
Function Web_Clients_Visit()

    With CodeContextObject
        Dim WebLink As String
        WebLink = "http://" & .[ClientURL] & ""
        Application.FollowHyperlink WebLink, , True
        HideWebToolBar
    End With
End Function
Simon
 

RSIboy

Registered User.
Local time
Today, 02:46
Joined
Jul 1, 2004
Messages
32
Thanks Simon

Apologies for not fully understanding you.... how/when would I call the function? I tried adding a button to the form, to the side of the field with the following

Private Sub WebBtn_Click()

With CodeContextObject
Dim WebLink As String
WebLink = "http://" & Forms!frmCompany.Web & ""
Application.FollowHyperlink WebLink, , True

End With

End Sub


(I had to remove the HideWebToolbar line - 'sub or function not defined')

However, I am getting a 'cannot locate the Internet server or proxy server' error. Any suggestions?
 

RSIboy

Registered User.
Local time
Today, 02:46
Joined
Jul 1, 2004
Messages
32
Further apologies - I have this working now! (I think it was missing a "www." from the actual record).

More generally what is the recommended way of dealing with a url field on a form? Rather than a button, would it be better to put this code in the 'On click' event of the actual field on the form?

Thanks for any suggestions....
 

Users who are viewing this thread

Top Bottom