Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2016
    Posts
    14

    Unanswered: How to open a JPEG attachment with one click in the default JPEG viewer?

    Hi,

    I'm building a form which contains a JPEG attachment.
    The attachment is displayed as "Image/Icon".
    I want to be able to open it in full size in my default JPEG viewer with simple one click on the attachment image.

    Thank you in advance!

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Code:
    btnOpen_ONCLICK
    dim sFile as string
       sFile = 'put file path here
       call shell("C:\program files\jpegViewer.exe " & sFile)
    end sub

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    or place an image control on the form (or even a sub form) and set the source of that image to be the file.
    you may need to do some other procressing (to handle where an image isn't recorded or if the specified image cannot be found.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jan 2016
    Posts
    14
    Quote Originally Posted by ranman256 View Post
    Code:
    btnOpen_ONCLICK
    dim sFile as string
       sFile = 'put file path here
       call shell("C:\program files\jpegViewer.exe " & sFile)
    end sub
    How to set the "sFile" to take the path from a filed in a table. The table in questions stores the paths to the images for each record (images are different for each record).

    Thanks!

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    sorry, frankly this is a pants way of doing this....
    it means spawning a instance of the file viewer then closing it...
    I'd strongly recommend that you use an image control INSIDE an Access form.
    then assign the value of your picture column (the column containing the file name + path) to that image control
    if all your photos are of currency and there is always a maximum of two images (face & behind) then it may make sense to use a tabbed dialog and have an image control on each tab. OR a radio button which the user selects which image they want to see. that radio group could be extended, based on the images you have (eg face, behind, side or whatever you need for your application
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by Kensei View Post
    How to set the "sFile" to take the path from a filed in a table. The table in questions stores the paths to the images for each record (images are different for each record).

    Thanks!
    have you tried to understand what ranman has posted

    he has already said
    Code:
    sFile = 'put file path here
    call shell("C:\program files\jpegViewer.exe " & sFile)
    so say the column containing your image is called img_face
    Code:
    sFile = img_face
    call shell("C:\program files\jpegViewer.exe " & sFile)
    or even
    Code:
    call shell("C:\program files\jpegViewer.exe " & img_face)
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jan 2016
    Posts
    14
    Thank you, healdem!

    I really do try to understand and I know I sound silly, but it's hard for me to write something when I only know only few pieces.
    I will do some tests based on your suggestions and will come back if there are any further question.

    The point of asking to open the images in the default image viewer is because I want to be able to easily open them in their full size.
    However this single-click-open issue isn't as important as my other one with storing the images separately from the database.

  8. #8
    Join Date
    Jan 2016
    Posts
    14
    I made an Image test db. However I wasn't able to succeed with opening the images, in an image viewer program, with a single click.
    I tried several times, but when I put sFile = Photo1 (Photo1 is the name of the column where the image path is stored) nothing happens.

    What do I miss? I attached some screenshots of the db.
    I highly appreciate your help!

    Click image for larger version. 

Name:	tblImage.jpg 
Views:	3 
Size:	78.1 KB 
ID:	16715Click image for larger version. 

Name:	frmImage_1.jpg 
Views:	3 
Size:	170.2 KB 
ID:	16716Click image for larger version. 

Name:	frmImage_2.jpg 
Views:	2 
Size:	172.0 KB 
ID:	16717Click image for larger version. 

Name:	Code.jpg 
Views:	3 
Size:	55.7 KB 
ID:	16718

  9. #9
    Join Date
    Jan 2016
    Posts
    14
    btw

    Quote Originally Posted by healdem View Post
    I'd strongly recommend that you use an image control INSIDE an Access form.
    ...
    if all your photos are of currency and there is always a maximum of two images (face & behind) then it may make sense to use a tabbed dialog and have an image control on each tab.
    I did it according to your advice. It turned out nicely.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •