How To Include ID Pictures In A Report (Access 2.0)

I work at a high school. Using Access, I need to print a one page report for each student which includes their picture as well as other data. There are over 1800 student pictures (jpeg format) in a directory on our server. Each of these pictures is named with a 4 digit number which is also the student's ID number (for example: 5327.jpg).

Here are the parameters I am using:

PicNum table field that contains path and picture name (i.e. S:7716.jpg)

StudentPhoto image control

PictureNumber bound text box control (bound to "PicNum" field)

With the above parameters in mind, I tried this solution using the following lines:

[PictureNumber] = [PicNum]
StudentPhoto.Picture = [PictureNumber]

This results in the error message: "Microsoft can't find the field 'I' referred to in your expression".
I put this code in the "Open" event in the report form. Is there a "Format" event? If so, I couldn't find it.

Other solutions I have tried are:

I set the bound PictureNumber control source to "PicNum" (field in database containing path & picture name).

With the above parameters in play, I have tried all of the following lines of code (one at a time, of course) and none will work. The error message I get each time is written in caps to the right of code line. If I don't prefix the word "report" to each control, then I get a "Microsoft can't find the field 'I' referred to in your expression".

Re: How To Include ID Pictures In A Report (Access 2.0)

Charlotte,

THANK YOU for your reply. It worked!

I am confused, however. It works fine in the "Detail" section but when I place the exact same code into the "Report_Open" section I get a "Type Mismatch" error message. Why is that? Since I am trying to learn here, I sure would appreciate a reason why this happens.

Re: How To Include ID Pictures In A Report (Access 2.0)

There isn't any reason to put it in th Open event. You want it in the report equivalent of the OnCurrent event, which is more or less the detail_format event. I don't know specifically why you're getting a type mismatch, but I suspect that your control may still be Null at that point.

Re: How To Include ID Pictures In A Report (Access 2.0)

Charlotte
I am trying to do exactly as this poster did i.e. to display a volunteer's photo in a report, but I can't work out what type of control (corresponding to the questioner's "StudentPhoto" image control) to put on the report . The control is to be called VolunteerPic ; I have tried an Image control, Unbound Object Frame control and Bound Object Frame control, but in every case, using the construct VolunteerPic.Picture errors
Run-Time error 438, Object doesn't support this method or property.
Clearly I've missed something fundamental.
What control should I be using/how do I get this working, please? BTW - I am using Access 2003.
Thanks
Silverback.

Re: How To Include ID Pictures In A Report (Access 2.0)

All working fine, now, thank you.
One thing fooled me for a bit, though. The report has a text box txtCover superimposed over the image control. What is the reason for this?
The VB code to make the image frame (in)visible seems to work fine without the need to hide it under another control.
Silverback.