Solved Display Image using Hyperlkink (1 Viewer)

Juett

Registered User.
Local time
Today, 05:44
Joined
Jul 16, 2019
Messages
71
Hi Everyone,

I'm trying to display an image in a report (once printed) by inserting a blank image control, and setting the source of the image control based on a hyperlink field.

Me!Image243.Picture = Me.Ctlhyperlink

But.....access stores the hyperlink as:

C:\Users\default\Pictures\1.jpg#C:\Users\busin\Pictures\1.jpg#...which then throws up an error when the report's VBA tries to set the source location of the picture.

Is there any way to store the hyperlink as just C:\Users\default\Pictures\1.jpg without the hashtags and the duplicated link?

Or...is there another way to set the image source in the report that I am not aware of?

Thanks very much
 

CJ_London

Super Moderator
Staff member
Local time
Today, 05:44
Joined
Feb 19, 2013
Messages
16,553
why store as hyperlink, just store as text

Me!Image243.ControlSource="='C:\Users\default\Pictures\1.jpg'"

note the single quotes, if this is referencing another control on the same form (perhaps Ctlhyperlink?) then all you need in the controlsource is

=Ctlhyperlink
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:44
Joined
May 7, 2009
Messages
19,169
Me!Image243.Picture = Split(Me.Ctlhyperlink, "#")(1)

or

If Me.Ctlhyperlink.IsHyperLink Then
Me!Image243.Picture = Me.Ctlhyperlink.Hyperlink.Address
Else
Me!Image243.Picture = Me.Ctlhyperlink
End If
 

Juett

Registered User.
Local time
Today, 05:44
Joined
Jul 16, 2019
Messages
71
arnelgp's solution worked perfectly. I amended it a tad to the below, so if there was no hyperlink, it would ignore it and still render the page:


If Not IsNull(Me.Ctlhyperlink) Then
Me!Image243.Picture = Split(Me.Ctlhyperlink, "#")(1)
End If

Thanks very much for your help.
 

Users who are viewing this thread

Top Bottom