Hi,
Records in my database contain the file paths of two pictures, a before and after, stored as txtPhotoPath and txtAFTERPhoto. On my report, I have two corresponding pictures, called RiskPhoto and AFTERPhoto.
I used the code below, which I adapted from something I found on this site, to display the pictures when the report is run. It's working fine - IN MOST CASES
However, we also have certain records WITHOUT an "after" picture, so txtAFTERPhoto is null in these cases. The problem is that rather than just printing an 'empty' picture, we're finding that the picture from the previous record is displayed in the report.
I think it's the error-handling that's at fault, but I'll be honest I don't really understand that bit.
I guess the previous picture is not being "cleared" but how do I achieve that?
Secondary question: To get this to work in the first place required a lot of trial and error. Mainly error in fact!! I now have this identical code in each of the following events:
I don't know which one (or more?) is being fired when I run the report, and I don't know which if any them is redundant and should be deleted. I can live with them, though, if the first question above can be answered.
Thank you very much.
Records in my database contain the file paths of two pictures, a before and after, stored as txtPhotoPath and txtAFTERPhoto. On my report, I have two corresponding pictures, called RiskPhoto and AFTERPhoto.
I used the code below, which I adapted from something I found on this site, to display the pictures when the report is run. It's working fine - IN MOST CASES
Code:
Private Sub Report_Activate()
' "Requery" the pictures
On Error GoTo Err_cmdClose_Click
'set picture paths
Me.RiskPhoto.Picture = Me.txtPhotoPath
Me.AFTERPhoto.Picture = Me.txtAFTERPhoto
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
If Err.Number = 2220 Then 'can't find the file
Resume Next
ElseIf Err.Number = 94 Then 'invalid use of null
Me.RiskPhoto.Picture = ""
Me.AFTERPhoto.Picture = ""
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdClose_Click
End If
End Sub
However, we also have certain records WITHOUT an "after" picture, so txtAFTERPhoto is null in these cases. The problem is that rather than just printing an 'empty' picture, we're finding that the picture from the previous record is displayed in the report.
I think it's the error-handling that's at fault, but I'll be honest I don't really understand that bit.
I guess the previous picture is not being "cleared" but how do I achieve that?
Secondary question: To get this to work in the first place required a lot of trial and error. Mainly error in fact!! I now have this identical code in each of the following events:
- GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
- Report_Activate()
- Report_Current()
- Report_Page()
I don't know which one (or more?) is being fired when I run the report, and I don't know which if any them is redundant and should be deleted. I can live with them, though, if the first question above can be answered.
Thank you very much.