Finding and displaying images on a report...

A

Albert S.

Hello,

I need to display some images on a report. The images are stored on another
PC - mapped to the Z:\ drive. The images are all named with the number
corresponding to the [ID] field. The images can be either a .jpg or .gif or
missing - there is no way to know except to look for it.

I am using a bound object frame with an embedded picture. Here is the code
so far (adapted from the help file):
'from the report detail - on print:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me!txtImageNote = DisplayImage(Me!ImageFrame, Me![ID])
End Sub
'function:
Public Function DisplayImage(ctlImageControl As Control, strImageID As
Variant) As String
On Error GoTo Err_DisplayImage
Dim strResult As String
Dim strImagePathGif As String
Dim strImagePathJpg As String

strImagePathGif = "Z:\" & strImageID & ".gif"
strImagePathJpg = "Z:\" & strImageID & ".jpg"

With ctlImageControl
If IsNull(strImageID) Then
.Visible = False
strResult = "No image name specified."
Else
.Visible = True
.Picture = strImagePathGif
strResult = "Image found and displayeed."
End If
End With

Exit_DisplayImage:
DisplayImage = strResult
Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function

The problem is that it never triggers the first IF, since every item has an
[ID] number. This code does display some images, but obviously, only with the
gifs. The only way I can tell that it is not a .gif when it goes to the eh.

My Questions:
1) How can I search for, and find the image if it is either a .gif or .jpg
or missing?
2) If the image is missing, how can I shift some text fields left to cover
the area where the image was going to be?
3) Some of the images are oriented (w by h) 135px by 180px, but some are
oriented 180px by 135 px. Is there any way to test for this? - BTW, not all
have the exact same dimentions.

Thanks for any help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top