Follow hyperlink from string (1 Viewer)

coasterman

Registered User.
Local time
Today, 09:28
Joined
Oct 1, 2012
Messages
59
The following code works but my instinct tells me this is not good coding and might cause me issues later, any suggestions? If it helps define the links will always be http:// links rather than file links.

Code:
Private Sub WebLink_DblClick(Cancel As Integer)
    Dim myLink As String

    If Not IsNull(Me.txtWebLink) Then
        myLink = Me.txtWebLink
        Application.FollowHyperlink (myLink)
    End If

End Sub
 

AccessMSSQL

Seasoned Programmer-ette
Local time
Today, 09:28
Joined
May 3, 2012
Messages
636
You can also just modify the property of the textbox that has the link. Change it's Is Hyperlink property to true and you won't have to write the code.
 

InitiallyMoved

New member
Local time
Today, 09:28
Joined
May 7, 2012
Messages
8
Do not use the Access hyperlink function.
Using the Windows API:

Code:
'Code in the module
Private Declare Function ApiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
 
Public Function ShellExecute(ByVal Command As String, _
                             Optional ByVal Parameters As String _
                            )
    If Len(Parameters) = 0 Then
        Parameters = vbNullString
    End If
    ApiShellExecute Application.hWndAccessApp, "Open", Command, Parameters, vbNullString, 1
End Function

Code:
'Sample
ShellExecute "www_access-programmers_co_uk" 'Replace "_" To ".", I can't post links.
ShellExecute "Notepad"
ShellExecute "MSACCESS", "C:\Sample.mdb"
......
 

coasterman

Registered User.
Local time
Today, 09:28
Joined
Oct 1, 2012
Messages
59
Thank you both. I had been warned off the followhyperlink by some other posts so I'm especially grateful for the API method, albeit the code is way in advance of my modest abilities.

This is sure to be added to my ever growing library of utility modules.
 

spikepl

Eledittingent Beliped
Local time
Today, 17:28
Joined
Nov 3, 2010
Messages
6,144
@Initially Moved: Now I am curious - what is wrong with using FollowHyperlink? Do you have some solid arguments or is it just yet another selfpropelling urban myth?

@Coasterman: Pray tell - what were the "warnings" concerning FollowHyperlink? Also, adding API's is not always a good thing maintenance-wise. I do it only if I have to.
 

coasterman

Registered User.
Local time
Today, 09:28
Joined
Oct 1, 2012
Messages
59
I'm no authority I can assure you and I'm only referencing the article by Allen Browne.

As to the issue of API's well I am certainly not qualified to comment, I don't really understand the code entirely but it seems to work in my particular project, I'll no doubt learn of any issues fairly soon once its deployed across the small network it's destined for.
 

AccessMSSQL

Seasoned Programmer-ette
Local time
Today, 09:28
Joined
May 3, 2012
Messages
636
Also, what are the draw backs to using the Is Hyperlink property on the textbox? Did a little bit of research and there are some issues with using these methods in Access 2007 on a Vista machine - but I would assume Vista would be the culprit in that case. Would like to find out more.
 

kilburfi

Registered User.
Local time
Today, 16:28
Joined
Jun 4, 2013
Messages
34
I have a database with a button to call a modal form. On that form is a hyperlink to a website. I have set it as a hyperlink and set the "is hyperlink" to yes in the properties but when I click on it nothing happens. Even if I right click and ask it to go to the hyperlink nothing happens. Any suggestions?
 

Users who are viewing this thread

Top Bottom