hyperlink field problem

SpiritedAway

Registered User.
Local time
Today, 10:41
Joined
Sep 17, 2009
Messages
97
Hi

On my form is a browse button that lets a user choose a pathway to a particular folder - the pathway to that folder is then displayed in a bound hyperlink field.

However the folder pathway is only showing in the hyperlinks "text to display" field and not in the hyperlinks "address" field.

Can anyone advise how to get the "address" field to display what's in the "text to display field" of the hyperlink?

Thanks for any advise you can give.

Using A2007
 
You could just use a Text data type instead if you don't want both Text to display and address to be the same. Then you can use Application.Hyperlink to open up the link.

Or am I misunderstanding what you're getting at?
 
Hi vbaInet,

The problem is - I'm using a button to open a browse dialog where I select a folder -

once i've selected the folder I want, the pathway, i.e C:/My Documents/Project Folder gets displayed in a bound hyperlink field [LinkField]

When I go to click on the hyperlink nothing happens.

The reason being is because the C:/My Documents/Project Folder is only showing in the "text to display" part of the hyperlink while the actual "address" is empty.

So i'm looking for a way to get C:/My Documents/Project Folder into the "address" field so it matches what's in the "text to display" field.
 
So if you manually Edit Hyperlink > go to folder and select it > Ok the dialog, then click on the hyperlink, it doesn't take you to the folder?
 
Hi vbaInet.

Decided to change the hyperlink field to a plain text field.

From there - created a button using the following code:

Code:
Private Sub bOpenFile_Click()
On Error GoTo Err_bOpen_Click

    Me.LinkField.SetFocus

    If IsNull(LinkField) Or LinkField = "" Then
        MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
    Else
        OpenFile (LinkField)
    End If

Exit_bOpen_Click:
    Exit Sub

Err_bOpen_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bOpen_Click

Found an old open file module which this relates too.

It now opens up the folder pathway perfectly.

For anyone wanting the module code (it isn't mine - I found it years ago somewhere on the net and had never used it until now)

Code:
Option Compare Database
Option Explicit

Declare Function ShellExecute 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 OpenFile(sFileName As String)
On Error GoTo Err_OpenFile

    OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:\", 1)

Exit_OpenFile:
    Exit Function

Err_OpenFile:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_OpenFile

End Function

Public Function TestOpeningFile()
On Error GoTo Err_TestOpeningFile

    OpenFile "C:\Windows\Win.ini"
    
Exit_TestOpeningFile:
    Exit Function

Err_TestOpeningFile:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_TestOpeningFile
    
End Function

So now I user a browse button to select a particular folder I want - the root pathway gets displayed in a textfield and the button [bOpenFile] opens up that folder.

Thanks again for your help vbaInet - it was your prodding that made me remember i even had this module.
 
Last edited:
Good to see that you've resolved the issue.

By the way you can condense the "check for null" code to this:
Code:
    If Len(LinkField & vbNullString) = 0 Then
 

Users who are viewing this thread

Back
Top Bottom