View Single Post
  #5  
Old July 30th, 2007, 04:55 PM posted to microsoft.public.access.reports
[email protected]
external usenet poster
 
Posts: 22
Default Problem with If.... Then.... Else.... Statement

Hi Richard
I've done something similar using the following
I have JPGsfile stored on my hard drive (of a photos of users) and the
path is in a table in the DB. Also in the folder is a default picture
where I don't have a photo for the user called NoPic.jpg

e.g. The table looks like this:
Name PictureLoc
Joe Bloggs c:/User Photos/JBloggs.jpg

I then have a textbox called PhotoLoc bound to the location in the
form. I've made it invisible so it won't appear on the form, but the
data is still there.
I also have a picture on form in the Details section. It can be
anything as it will be replaced when the form is rendered. I recommend
using the NoPic.jpg. Make sure it's the correct size for your report.
You can set the Size Mode property to stretch or clip depending on how
you want your images to look. I've named the picture PhotoFrame

Then I have the following code for the form:

'----------------------------------------
Function setPhotoPath()

Dim PhotoPath As String
On Error GoTo PhotoNotAvailable
PhotoPath = Me.PhotoLoc
Me.PhotoFrame.Picture = strPhotoPath

PhotoPictureNotAvailable:
PhotoPath = "C:\User Photos\NoPic.jpg"
Me.BoxFrame.Picture = PhotoPath

End Function
'--------------------------------------------

Finally, I have "=setPhotoPath()" (without quotation marks) in the On
Format section of the properties of the report details.

When I preview the report, the query is run to bring up the location
of the jpeg and the code replaces the picture.

Hope this helps. If you want an example DB, I can send you one.

Tony