Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Loading a JPG into and Image control when report is run 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
We have signatures that need to show on a report. Each persons signature is a jpg. When I added the image control I was able to load one signature which showed up just fine. It was embedded. We need to be able to change the signature as each line in the sub form changes to that person, In other words the sub report will have a bunch of signatures on it different for each person or record on that subreport. I want to open the signature jpg files and load it into the image control when the report is opened.
This code worked OK on a Form which I have used a lot of times. But it gives an error on this subreport.
Error # 2220 Microsoft Office Access can’t open the file ‘2097487935’
Whatever that means, The file name is SignatureImage = “Fred Flintstone.jpg”
The image control Picture Type is Linked now.
This code is in the subreports Page Event.
Code:
    ' load image into image control on report
    SignatureFileName = "F:\Signatures\" & SignatureImage
    Me.Signature.Picture = LoadPicture(SignatureFileName)

If I change the code to this, I don’t get an error but there is nothing showing in the image either.
Code:
    Me.Signature.Picture = SignatureFileName


DougP
[r2d2] < I Built one
 
Subreports don't have a page event that would fire. I would try the second code in the On Format event of the report section that contains the image control. SignatureImage must be a bound control in that report section however it could be invisible.


Duane
Hook'D on Access
MS Access MVP
 
If I have an OLE object as a field in the table which makes it bound. Would each record end up with a .jpg in it? I would prefer not to load the datbase with an image for each record as this bloats it very quickly.

DougP
[r2d2] < I Built one
 
I would not create the OLE Object fields to store the images. I'm not sure what format is used to store the actual image in the table.

Did you try the modifications I suggested? Can you provide any feedback?

Duane
Hook'D on Access
MS Access MVP
 
Ok I still get an error and this time I brought al the code
Its in the Detail_Format event
error on red line below
Error #2220 Microsoft Access can't open the file '-2080041645'
The file in question is
F:\Signatures\ArielArmaiz.jpg which is there I just checked it.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    On Error GoTo Err_Detail_Format
    
    Dim SignatureImage As String
    
    'find signature image
    Select Case Me.Report.[PCMSamples subreport]!Technitian
        Case "Ariel Armaiz"
            'SignatureImage = "Armaiz, Ariel.jpg"
            SignatureImage = "Ariel Armaiz.jpg"
        Case "Douglas Poston"
            SignatureImage = ""
        Case "Glenn Hargrove"
            SignatureImage = ""
        Case "Joe Haran"
            SignatureImage = "Haran, Joe.jpg"
        Case "Jon Bixler"
            SignatureImage = "Bixler , John.jpg"
        Case "James F. Rizk"
            SignatureImage = "Rizk, Jim.JPG"
        Case "Laura Gicker"
            SignatureImage = ""
        Case "Michael Cross"
            SignatureImage = ""
        Case "Nacole Bowersox"
            SignatureImage = "Bowersox, Nacole.jpg"
        Case Else
            MsgBox "Employee Name is not Select Statement"
    End Select
    
    If SignatureImage = "" Then
        MsgBox "Signature not found"
    End If
    
    ' load image into image control on report
    SignatureFileName = "F:\Signatures\" & SignatureImage
    [COLOR=red]Me.Report.[PCMSamples subreport]!Signature.Picture = LoadPicture(SignatureFileName)[/color]


Exit_Detail_Format:
Exit Sub

Err_Detail_Format:
    Select Case Err.Number
        Case 3021
            ' No current record
            
        Case Else
            MsgBox "Error # " & Err.Number & "  " & Err.Description, vbInformation, "In sub Detail_Format"
            
    End Select

    Resume 'Exit_Detail_Format
End Sub

DougP
[r2d2] < I Built one
 
My initial section was to not use the LoadPicture function. I liked your other code that simply set the picture property to the string. Also, you should be able to use Me! since the code should be running in the subreport.
Code:
Me!Signature.Picture = SignatureFileName

Duane
Hook'D on Access
MS Access MVP
 
I do need the subreport stuff since there is a subreport inside the details section and the simple ”Me!” said field not found.
Ok this works now,
Code:
Me.Report.[PCMSamples subreport]!Signature.Picture = SignatureFileName

but it puts the same signature for each record. I only have two records right now, Joe and Ariel. and the code loops through twice.
But its putting Ariel’s signature for both. Ariel is the first record. The select statement goes into Case "Ariel Armaiz" both times. I guess I need something to ‘movenext' record somehow? The rest of the report shows both records correctly...


DougP
[r2d2] < I Built one
 
I try to run the code in the same container that it is manipulating. If you want to change an image in a subreport, I like to put the code in that subreport. If the subreport is burried in another subreport, run the code in the sub-subreport. You can use the Me.Parent property to reference the higher level object/report.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top