Image references

P

paul bennett

I have a large number of photos linked to display in a report and a form.
This is set up so that the image frame will look for the appropriate file
without incorporating it as an OLE object:

'define the photo file name'
Dim thePhotoPath1 As String
thePhotoPath1 = theDbFolder & "GazetteerMaps\" & theSite & ".jpg"
Dim thePhotoPath2 As String
thePhotoPath2 = theDbFolder & "GazetteerPhotos\" & theSite & ".jpg"

'set each image frame to contain a photo
Me.ImgPhoto1.Picture = thePhotoPath1
Me.ImgPhoto2.Picture = thePhotoPath2

Presently, there needs to be a file for every site, or I get an error
message to debug. Is there some code that will tell the image frame
(ImgPhoto1 and 2) to display a default image or to simply not display in the
event of a photo not being present?
 
J

John Smith

Use the Dir command:

If Dir(thePhotoPath1) = "" Then
' Do whatever you wish when there is no file
Else
Me.ImgPhoto1.Picture = thePhotoPath1
End If

HTH
John
##################################
Don't Print - Save trees
 

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