Discussion Locked

Adding a photo to a form and a report

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a form I am developing in Access. People from around the state scan pictures and want to put that photo and a description of the person in an access database to retrieve later. Once entered into a form, this is then emailed as a report in snapshot view to all other members of this group.
My problem, how do I get a photo to pop up on the form based on last name of the individual. I have tried a image frame, a bound image frame and unbound image frame. The one that sorta works is the image frame, but it doesn't transfer the picture to the report.
I want the picture to pop up as a result of the on change event of the last name.
Any ideas? Thanks so much! Connie

7 replies

by dklippert

Take a look at the Northwind database sample (Northwind.mdb) that should have been installed with Access. The Employee form has what you want.
The photo in an OLE Object. It is entered using Insert Object as a field in each record. The Form uses a Bound Object Frame.

by creed

No this didn't help, I may or may not have a pictureso I need to decide if the picture matches the last name property and if it does, then attach the photo to the record and attach it permanently so it also reproduces on the automated report. Thanks anyway, it was a good try.

by bob sellman

Use an image control to hold the picture. Make it an embedded image and you'll have to define a "default" picture when you define the image control. Use embedded type of image.

The real question is where is the picture saved. I'd suggest saving each picture as a separate image file named according to whatever convention you want to use. SSN's are good because each person's is different (unlike last names, which could be duplicated). But let's assume you can use the last name without problem (we'll also ignore names with apostrophes for now) and your pictures are saved (in a folder C:\ThisApp\Images) in the format LastName.jpg (jpg format file).

I'm going to assume that you have a control (visible or hidden as appropriate) calledtxtLastName that contains the LastName. What you need to do is load the picture property of the imgPhoto control with the name of the image file for each record displayed. Do something like this:

Use the onCurrent property of the form or reportand the following code:

me.imgPhoto.picture = "C:\ThisApp\Images\" & me.txtLastName

The picture of that person will then be displayed.

If you also permit changing the last name you should also put the same code in the AfterUpdate property of the txtLastName control.

by creed

Thanks for all your help!!!How did you learn so much about the VBA code behind Word? I'd like to be able to code that easily. Again, Thanks!!!

This discussion is closed to new replies.