Picture shows on form but not on Report

dcavaiani

Registered User.
Local time
Today, 08:10
Joined
May 26, 2014
Messages
385
I've got a link to a picture stored on C drive and it works well with my single page form. On a report from the same query source, I would like the same picture to appear on each of the group header lines. If I hard code a logo in the picture property, the logo shows up. But, the individual picture does not show up on the report when it is coming from the address in the table?
 
Usually the file path is in a hidden textbox control and the control source of the image is set equal to the textbox. If this is how you have it set up then I suggest making the textbox temporarily visible to make sure the file path is ok. Also control the compare the form's set up with the report's set up. I suspect something is different.

If you can't figure it out if you upload your database I'll have a look.
 
Sorry but this may take me a while to fully understand. The simple set up I talked of in my previous post isn't true for the earlier versions of Access. In your version you need some code to get an image displayed. I haven't dealt with this code so it will take me a while to figure it out. The code I'm referring to is the following:

'
Code:
 Display the picture for the current employee record if the image
    ' exists.  If the file name no longer exists or the file name was blank
    ' for the current employee, set the errormsg label caption to the
    ' appropriate message.
    Dim res As Boolean
    Dim fName As String
    
    path = CurrentProject.path
    On Error Resume Next
        errormsg.Visible = False
        If Not IsNull(Me!Getpic) Then
            res = IsRelative(Me!Getpic)
            fName = Me![ImagePath]
            If (res = True) Then
                fName = path & "" & fName
            End If
            
            Me![ImageFrame].Picture = fName
            showImageFrame
            Me.PaintPalette = Me![ImageFrame].ObjectPalette
            If (Me![ImageFrame].Picture <> fName) Then
                hideImageFrame
                errormsg.Caption = "Picture not found"
                errormsg.Visible = True
            End If
        Else
            hideImageFrame
            errormsg.Caption = "Click Add/Change to add picture"
            errormsg.Visible = True
        End If

which is in the On Current event of the form. Also it's in the On Current event of report but that event doesn't seem to be firing. I copied and pasted this code into the On Format event of the GroupHeader2 and after commenting out any references to errormsg I got the image to display in the print preview view. So I'm making progress.

So I need to do a little research and find out how this is normally done in your Access version. I'll get you something as soon as I can. Meanwhile maybe one of our forum members with your version of Access will help out.
 
Update: Instead of looking at the report On Current event I was looking at the Form On Current event code which somehow along with all the other form module code turned up in in the report module. :) When I put the following code in the actual Report On Current event as shown below I get the image in the report.

Code:
Private Sub Report_Current()
 ' Display the picture for the current employee record if the image
    ' exists.  If the file name no longer exists or the file name was blank
    ' for the current employee, set the errormsg label caption to the
    ' appropriate message.
    Dim res As Boolean
    Dim fName As String
    
    path = CurrentProject.path
    On Error Resume Next
     '   errormsg.Visible = False
        If Not IsNull(Me!Getpic) Then
            res = IsRelative(Me!Getpic)
            fName = Me![ImagePath]
            If (res = True) Then
                fName = path & "" & fName
            End If
            
            Me![ImageFrame].Picture = fName
            showImageFrame
            Me.PaintPalette = Me![ImageFrame].ObjectPalette
            If (Me![ImageFrame].Picture <> fName) Then
                hideImageFrame
      '          errormsg.Caption = "Picture not found"
       '         errormsg.Visible = True
            End If
        Else
            hideImageFrame
        '    errormsg.Caption = "Click Add/Change to add picture"
         '   errormsg.Visible = True
        End If


End Sub

Note that I commented out the lines with a reference to errormsg. I guess the form has that control but not the report. I think that all we need to do is to rework this code so that it's right for the report. You will need to decide how you want to handle the case where there is no image file. Do you want to display an image that says no image or just leave the space blank.
 
If you look, I did find/copy some code from somewhere a while back (it's in there, and works on the form, but the same code is failing on the report. I am not a code writer, I really don't understand it well. I am in no hurry. I appreciate all you can help with!
 
I deleted all code, re-copied all the form code back in (I know some is superfluous). Then, like you suggested, I copied a part of the code under the Print event for the Group Header. I will check further in the morning, but seems like it works now. I am very grateful. I could not find a Current event option for the report (on Access 2002).
 

Users who are viewing this thread

Back
Top Bottom