Microsoft VBA view a JPEG file on click event

HI

I am using Office 365 - Microsoft Access,  continuous form.   There is only one computer monitor at this time.  

I would like a photo of a [stockitem]  to pop up on a  click event .   The format of the file would be jpeg.   The file would be accessed strictly to view.   There would be no editing.  


Is there a control in Microsoft Access that handles this easily,  or should I use some sort of shell command?  I've seen references to "LoadPicture".

In this case, the file name might be C:.\Photos\2043.jpeg  

 Thank you
peispudAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony BerenguelCommented:
This should suit your purpose.
application.followhyperlink "the filepath of the jpg" 

Open in new window

0
peispudAuthor Commented:
That works. Thank you.

I would like to avoid the  a pop-up warning that comes up every time.
0
Anthony BerenguelCommented:
what does the pop-up say?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

peispudAuthor Commented:
This is on a Windows 10 machine.

It says

A potential security concern has been identified

Hyperlinks can be harmful to your computer and data... etc

and then

do you want to continue y/n
0
Nick67Commented:
There's many different ways to decide to handle it.
Access has an Image control.
This can be bound to a path such as "C:\Photos\2043.jpeg"
The control will display the image.
Check my articles.  I have lots of stuff about images.

There's Win API
Here's some nice code.  Put it in a module
Option Compare Database
Option Explicit
Public 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
'***App Window Constants***
Public Const WIN_NORMAL = 1         'Open Normal
Public Const WIN_MAX = 3            'Open Maximized
Public Const WIN_MIN = 2            'Open Minimized

'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&



Function fOpenFile(stFile As String)

    ' This function uses ShellExecute to open the file.

    Dim lRet As Long, varTaskID As Variant
    Dim stRet As String

    lRet = apiShellExecute(hWndAccessApp, "Open", _
            stFile, vbNullString, vbNullString, 0&)
            
    If lRet > ERROR_SUCCESS Then
        stRet = vbNullString
        lRet = -1
    Else
        Select Case lRet
            Case ERROR_NO_ASSOC:
                stRet = "Error: No associated application.  Couldn't open!"
            Case ERROR_OUT_OF_MEM:
                stRet = "Error: Out of Memory/Resources. Couldn't open!"
            Case ERROR_FILE_NOT_FOUND:
                stRet = "Error: File not found.  Couldn't open!"
            Case ERROR_PATH_NOT_FOUND:
                stRet = "Error: Path not found. Couldn't open!"
            Case ERROR_BAD_FORMAT:
                stRet = "Error:  Bad File Format. Couldn't open!"
            Case Else:
        End Select
    End If
    fOpenFile = lRet & _
                IIf(stRet = "", vbNullString, ", " & stRet)
End Function
Sub OpenJpg(FullPath As String)
Dim OpenThis
OpenThis = fOpenFile(FullPath)
If OpenThis <> -1 Then
    MsgBox OpenThis
End If
End Sub

Open in new window


feed it OpenJpg("C:\Photos\2043.jpeg") and it will open that file in the default Windows program for that file extension
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nick67Commented:
This can be bound to a path such as "C:\Photos\2043.jpeg"
In Access 2010 and later it can be bound to a field containing paths, and then each row of the form will display the unique image bound by the field.
You may want some thumbnail size images for that, and then a click to open a new popup form with the full size -- or just a popup with a large image control bound to the path
0
Anthony BerenguelCommented:
try this
docmd.setwarnings false
application.followhyperlink "the filepath of the jpg" 
docmd.setwarnings true

Open in new window

0
peispudAuthor Commented:
The code provided by Nick67 worked flawlessly. I will look at your articles.
I also appreciate the help that Anthony Berenguel gave me.
Thank you all.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.