Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this possible to do in a report. HELP PLEASE !!

Status
Not open for further replies.

afrim

Technical User
Oct 18, 2001
4
MK
Hi to all,
I have a form that has pictures of each person on it. The pictures are stored in a file which the filename refers to the field on the db. I refer to those file names using this code, and I get right fotos for every single person.
Here is the code I use:

Private Sub Form_Current()
If Me![ID] <> 0 Then
Me!Image4.Picture = &quot;F:\Fotos\&quot; & Me![ID] & &quot;.jpg&quot;
End If
End Sub

How do I DO THE same thing on a REPORT?
I keep getting the same foto for every record which refers to the last row in the database field.
Here is the code I use:

Private Sub Report_Activate()
Dim db As Database
Dim rs As dao.Recordset
Dim sRec As String
Dim strID As String

Set db = CurrentDb()
Set rs = db.OpenRecordset(&quot;select ID from Employees&quot;)

Do Until rs.EOF
If rs.Fields(&quot;ID&quot;) <> 0 Then
strID = rs.Fields(&quot;ID&quot;)
Me!Image29.Picture = &quot;F:\Fotos\&quot; & strID & &quot;.jpg&quot;
rs.MoveNext
Else
Print &quot;something&quot;
End If
Loop

rs.Close
Set rs = Nothing

CAN ANYBODY JUST LETS ME NOW IF THIS EVEN POSSIBLE.
I HAVE A DEADLINE SOON, SO AT LEAST I COULD THINK SOMETHING ELSE.

Thanks in advance.

Afrim
afrim.shala@omik.org
 
Try just this code in your property sheet of your image control in its control source property

= &quot;F:\Fotos\&quot; & [ID] & &quot;.jpg&quot;

This supposes that the ID field is part of the reports current recorset.

I hope this helps,
Rewdee



 
Hi Rewdee,

I did try that before and after u wrote, but still dosent work. There is a thread bit similar to this, but I just dont understand did this gy manage to do the same thing in a report. Anyway the thread number is: thread703-143845
and has been posted at Oct 3, 2001 by Patrick1(TechnicalUser).
So Patrick if u read this msg, can u please giveme a hint.

Thanks anyway Rewdee.
 
Have never done this, but looks like fun so I read the thread and FAQ you refered to. I noticed 2 things:

1. Patrick said there has to be a Control on the report that holds the ID. Your post doesn't make clear, do you have such a control on your report, or are you just refering to the field in the recordset?

2. Patrick didn't say which event he put his code in, but the FAQ was about the On Current event of a form. I've notice the On Format event of the detail section of a report tends to correspond to that.

Good luck, and please post your solution for when I get around to giving it a try!
 
Hi tempclerk!

I just wonted to inform that I did have a control too(tex-box control which refer to the field in db but didnt help,I dont now..) but in the code above I do refer to the field in the recordset.

Thanks anyway,
Afrim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top