Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    View a jpeg file from Access (2K)

    I have a database in which I have a report (based on a query) that pulls data from a form. When a certain field in the form contains a filepath name to a jpeg file on my computer, I would like whatever image program I have to open the jpeg file when I open the report for a particular record.

    I would also like to place a command button on the form that would open the image program and then the jpeg file based on the filepath name in the current record's field (as a way to check the accuracy of the file path to the jpeg file before printing the report).

    I have seen some of the posts dealing with issues like this one and I am a little confused. Do I need to add the ShellExecuteA function in a module of my db? And where it calls for a particular filepath name do I insert the field I want it to get the filepathname from (i.e. [strScannedDocument] ) with some type of criteria?
    Easy Access

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: View a jpeg file from Access (2K)

    I don't understand what you are trying to do.

    I would think that you would want the image to be included in the report, so that it will be printed with the report. If you open the image in a separate program, it won't be printed with the report - at least not automatically.

    To include an image in a report, place an image control in the detail section of the report (not an OLE control), and write code for the OnFormat event of the detal section to load the jpeg image from the file path into the image control. The code could look like this (the image control is named imgPic in this example; replace it by the name you use):

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    On Error GoTo Err_Sub
    If IsNull(PicFile) Then
    [imgPicture].Visible = False
    [imgPicture].Picture = ""
    Else
    [imgPicture].Visible = True
    [imgPicture].Picture = [strScannedDocument]
    End If
    Exit Sub
    Err_Sub:
    ' Error 2220 means can't open file
    If Err = 2220 Then
    [imgPicture].Visible = False
    [imgPicture].Picture = ""
    Else
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

    To open the jpeg image in whatever graphics application is associated with jpeg files on your system (for instance from a command button on a form), you can use Application.FollowHyperlink, or ShellExecute. The declaration for ShellExecute can be in any module, but if you want to be able to use it throughout your database, you should put it in a general module (not a form or report or class module). If you supply the name of the field containing the file path, the value for the current record will be used.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: View a jpeg file from Access (2K)

    Hi Hans,
    Thanks for the response. I have tried an image control, but that doesn't work for me because what will be scanned is a document that is usually the size of a full sheet of paper. Trying to insert this into an image control in my report makes either the page too wide and the scanned document does not all fit.
    Is there a way to reduce the ratio automatically to fit in my report? If that were the case then the image control would work fine.
    Easy Access

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: View a jpeg file from Access (2K)

    You can set the SizeMode property of the image control to Clip, Stretch or Zoom. If you set it to Zoom, the image will fit inside the control without distortion (stretch makes it fit inside the control with distortion if necessary; Clip shows the image at its original size, displaying only part of it if it's too large).

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: View a jpeg file from Access (2K)

    Hello Hans!

    Thank you for your suggestions. I used the Application.FollowHyperlink and your example of VBA for my report and they worked great. I appreciate your help and you have my undying gratitude. <img src=/S/bow.gif border=0 alt=bow width=15 height=15>
    Easy Access

Posting Permissions

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