Photo of members on the report

  • Thread starter Frank Situmorang
  • Start date
F

Frank Situmorang

Hello,

I want to have the photo in the report, it has worked in the formm but I
want to work also on the report.

For some record which has no photo, it will only show " no picture". This is
my VBA, it works for no picture, but for the one has picture ( in the sample
I have 1 picture, it just bring the same picture to the next record, even
though the image path is null.

This is my VBA:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error Resume Next
If Not (IsNull(Me.ImagePath)) Then
Me.Imageforrpt.Picture = Me.ImagePath
Else
Me.Imageforrpt.Picture = "C:\Private\Churchdata\Nopicture.jpg"
End If

End Sub

I do not know what is wrong on the above,

Thanks in advance
 
E

Evi

I didn't quite get all you've said so just check that I've understood
correctly

I'm assuming that you are saying (and from seeing your code) that you have
a table which has a field called ImagePath which contains the path to the
picture and its name. This ought to be (and looks as if it is) a Text
field - not an OLE field, so that you don't have to store all those photos
in your database which could grow too bloated to survivie if revival
strikes!

The field may be linked say, to a table of church members and you want
their photo to appear next to their name in your report.

In your report, you have put a picture by going to Insert & Picture,
choosing any picture and then deleting its file path next to where it says
leaving you with a blank ImageFrame waiting to be filled by code in the On
Print Event of the section that contains the ImageFrame. This seems to be
the Detail section, from your code. Correct so far?

You have named that control (again, according to your code) Imageforrpt


You want to load that picture into your report for that person but if you
have no picture for that person you will leave the ImagePath field blank.
Then you will want a default picture called NoPicture.jpg to appear in the
report.

But instead of the correct image for each record contains this Default
Picture. Still Correct?

If yes, then it is possible that your ImagePath field actually contains a
Zero Length String rather than Null.

Test for this by, instead of just IsNull use

If IsNull(Me.ImagePath) OR Me.ImagePath = "" Then
Me.Imageforrpt.Picture = "C:\Private\Churchdata\Nopicture.jpg"
Else
Me.
Me.Imageforrpt.Picture = Me.ImagePath

Alternatively, you may not have typed your file path and/or its file
extension accurately (your photos may not be JPGs for instance, and the On
Error is hiding this fact
or the lack of a suitable replacement is causing the image to keep what you
had already pasted into the report - ie you didn't delete the value next to
Picture when you inserted the Image Frame.

As a tip, take out the On Error Resume Next until you are sure that your
code works OK. Error Messages are like 10 Commandments - they can tell you
where you are going wrong, even if you aren't always able to put it right by
yourself.

Evi
 
E

Evi

Oops! code typo

Should be

If IsNull(Me.ImagePath) OR Me.ImagePath = "" Then
Me.Imageforrpt.Picture = "C:\Private\Churchdata\Nopicture.jpg"
Else
Me.Imageforrpt.Picture = Me.ImagePath
End If

Evi
 
B

Bill

Sometimes strings need to be tested as such, in that
whether null applies can be questionable.

Try this:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error Resume Next
If len(Me.ImagePath & "") > 0 Then
Me.Imageforrpt.Picture = Me.ImagePath
Else
Me.Imageforrpt.Picture = "C:\Private\Churchdata\Nopicture.jpg"
End If

End Sub


Bill
====================================================
 
F

Frank Situmorang

Evi,

Your are right Evi, your code is ok, it works fine now. It was my mistakes
Please disregard my previous posting

With many thanks
 
F

Frank Situmorang

Evi & Bill:

Thanks for your quick response.

Sorry..may be I have language problem in expressing my difficluties.

What I meant to say is this:

When I view report based on my code either your suggestion the report comes
out like this:

the one has no picture
Name Imagepath picture frame
-------- ------------ ---------------
jason blank no picture
frank c:/Private... there is picture
charlie blank same picture as above/fran
bob blank same picture as abve/frank

Although imgae path is zero is still shows like the previous picture

Jason
 
M

Michiel Rapati-Kekkonen

if there's no picture then

Me.Imageforrpt.Visible = False

Michiel



Frank Situmorang said:
Evi & Bill:

Thanks for your quick response.

Sorry..may be I have language problem in expressing my difficluties.

What I meant to say is this:

When I view report based on my code either your suggestion the report
comes
out like this:

the one has no picture
Name Imagepath picture frame
-------- ------------ ---------------
jason blank no picture
frank c:/Private... there is picture
charlie blank same picture as above/fran
bob blank same picture as abve/frank

Although imgae path is zero is still shows like the previous picture

Jason
 

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