Hyperlink Button Run Time Error

funwithaccess

Registered User.
Local time
Today, 05:11
Joined
Sep 5, 2013
Messages
80
Hi all,

I am attempting to create a form (Access 2013) that will include buttons to open the hyperlink menu to add a hyperlink into a table. It works if you click "Ok" without issue, however, if you click "Cancel" or click on the "X" I get a "Run-time error '2501' - The RunCommand action was cancelled". This is obviously referring to the RunCommand in the VBA code. The code does not reference the cancel or close option of the hyperlink editing box. I don't know how to correct this error.

Code:
Private Sub Command9_Click()

    Me.[Hyperlink].SetFocus
    DoCmd.RunCommand acCmdInsertHyperlink


Command9_Click_Exit:
    Exit Sub
    
Command9_Click_Err:
    MsgBox Error$
    Resume Command9_Click_Exit
    
End Sub

Also, is there a way to get the hyperlink to populate as the full network path and not the drive letter?

As always, thank you in advance! This forum is one of the best out there.

Nate
 
Carefully exit if the Error 2501 occurs.. Refer a good Error handling procedure..

Regarding your second question to get the UNC path.. Use the function..
Code:
Function getUNC(pName As String) As String
[COLOR=Green]'***********************************
'Code Courtesy of
'  Paul Eugin
' USAGE: 
'     ? getUNC("N:\")
'       \\serverName\driveName\
'**********************************[/COLOR]
   Dim sDrive As String, iVar As Long

   sDrive = UCase(Left(pName, 2))

    With CreateObject("WScript.Network").EnumNetworkDrives
        For iVar = 0 To .Count - 1
            If .Item(iVar) = sDrive Then
                getUNC = .Item(iVar + 1) & Mid(pName, 3)
                Exit For
            End If
        Next
   End With
End Function
 
Thank you! I was pulled away to work on something else, however, I will try it on Monday.
 

Users who are viewing this thread

Back
Top Bottom