create hyperlink from text field

gtech08

New member
Local time
Today, 10:26
Joined
Aug 18, 2004
Messages
8
I'm using a function from the Microsoft Knowledge Base to import images into an image control on a form. The function works fine, but I would like the image to also be a hyperlink so you can view the full-size picture by clicking on it. Here's the code for the function:

Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
On Error GoTo Err_DisplayImage

Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer

With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = "No image name specified."
Else
If InStr(1, strImagePath, "\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
strDatabasePath = Left(strDatabasePath, intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Image found and displayed."
End If
End With

Exit_DisplayImage:
DisplayImage = strResult
Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function

So basically I just want the hyperlink of the image to point to the path of the image. I tried just adding ".Hyperlink = strImagePath" after ".Picture = strImagePath", but that didn't work. I'm new to Visual Basic so any help is greatly appreciated.
 
nevermind

Should have been ".Hyperlink.Address = strImagePath"
 

Users who are viewing this thread

Back
Top Bottom