Records in my database contain (among other things) the paths to two jpegs, "before" and "after" pictures. In any given record, one or both of these may be null.
My report prints one record to a page and prints the pictures using the following code which I adapted from something I found before on this site.
I have two test records in my database. Record1 has both paths completed; Record2 has only the "Before" path completed. However, when I print the report, the "After" picture from Record1 is printed on BOTH pages.
So the picture needs to be "blanked" or "nulled" or whatever you can do to pictures, if the relevant path is null. I thought that's what the code did, but evidently not.
A previous suggestion was to use an image with the words "No Image selected" or something like that, but I have two problems with that:
1) I can't expect the user to have to specify a picture to say, in effect, "There is no picture".
2) I can't set the path to the "No Image selected" picture by default, because its location will be different on every machine and this needs to work on several standalone PCs, mainly in other firms.
I'm convinced there's a fairly simple correction needed to the code to make it do what I want. Put simply, if any record has only one picture, I want a blank space to be left on the page in it's place. But the picture from the previous record is being retained somehow.
I also tried this...
...and I thought I was onto something but I couldn't make it work. I don't really DO code, I'm afraid
Which is why I need help!!
My report prints one record to a page and prints the pictures using the following code which I adapted from something I found before on this site.
Code:
Private Sub Report_Page()
' Two "pairs" of controls:
' 1a txtPhotoPath 1b RiskPhoto
' 2a txtAFTERPhoto 2b AFTERPhoto
'
' 1a and 2a are from the report's underlying query
' 1b and 2b are images on the report
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 = "" ' <-- Do these lines mean the
Me.AFTERPhoto.Picture = "" ' <-- picture will be blank?
Resume Next ' That's what I'm trying to do!
Else
MsgBox Err.Description
Resume Exit_cmdClose_Click
End If
End Sub
I have two test records in my database. Record1 has both paths completed; Record2 has only the "Before" path completed. However, when I print the report, the "After" picture from Record1 is printed on BOTH pages.
So the picture needs to be "blanked" or "nulled" or whatever you can do to pictures, if the relevant path is null. I thought that's what the code did, but evidently not.
A previous suggestion was to use an image with the words "No Image selected" or something like that, but I have two problems with that:
1) I can't expect the user to have to specify a picture to say, in effect, "There is no picture".
2) I can't set the path to the "No Image selected" picture by default, because its location will be different on every machine and this needs to work on several standalone PCs, mainly in other firms.
I'm convinced there's a fairly simple correction needed to the code to make it do what I want. Put simply, if any record has only one picture, I want a blank space to be left on the page in it's place. But the picture from the previous record is being retained somehow.
I also tried this...
Code:
ElseIf Err.Number = 94 Then 'invalid use of null
Me.RiskPhoto.Visible = False
Me.AFTERPhoto.Visible = False
Resume Next
...and I thought I was onto something but I couldn't make it work. I don't really DO code, I'm afraid

Which is why I need help!!