How to insert a picture in a database

F

Frankie Deschacht

I was wondering how I can insert a .JPEG file into a database, so that it
appears as a normal visible field.
I have a database with students in, and I think it would be good if, for
every record, apart from their personal details, you could also see their
picture, without having to click on it first to activate it in a different
window.
I have an OLE Object field, called "Photo", but I am now stuck to reach my
goal.
Any suggestions anyone?
Thanks,
Frankie.
 
E

Evi

Images don't appear in the tables, you will see them in forms and reports.

Put your photos in a folder which you could put inside the photo that has
your databases.

Make a table with 2 fields, an autonumber field called ImageID and a text
field called Image.

In Image type the file name of each photo (there is code that will do that
for you if you already have lots of photos)

In your Students table have a text field called eg PhotoPath

Make its Default Value the path to your photo folder eg

"C:\My Documents\MyDataBases\StudentPhotos\"

Use an update query to update your past records.

Have another field in your Student table called ImageID which links from
ImageID in your Image table.

One of your pictures could be a dummy eg a white square so that you could
use this picture's ImageID as the Default value in your Student Table.



In a query based on your student table and the Image field from TblImage put
a field to join image and file page

StudentPic: PhotoPath & Image.

Base a Single form on this query

In design view add an Image Control.

Let it browse to your dummy picture.

In the Properties box of the Image control (note its name, lets call it
Image32), next to Picture you will now see the file path.

Next to Picture Type choose Linked.

Now click in the grey area below the the form so that the Properties box now
says your Form's name at the top.

Click on the Events tab, click next to On Current and choose Event
Procedure. Click just right of that to open a code page.

Type between the code lines so that the code now looks like this>

Private Sub Form_Current()
Me.Image32.Picture = Me.StudentPic
End Sub

This will load the correct picture each time you turn the page.

Say if you want to do a report too or if you don't understand something and
I'll tell you, otherwise this message is getting to look like War and Peace.

Evi
 
D

dbracey

All you have to do is place an "Image" on the form. You do this by
clicking on the "Image" button and then clicking on the form. You will
then be prompted to add an image using the standard directory
navigation window in windows.

It's pretty cut and dry, hope it helps.
 
F

Frankie Deschacht

Thanks so far Evi,
but when I get to the step where I have to go into the Events tab and click
"On Current", that option is not there.
All I have is : On Click, On Dbl Click, On Mouse Down, On Mouse Move and On
Move Up.
Where do I go from here ?

Thanks,
Frankie.
 
E

Evi

You're not clicking on the right bit, Frankie. Click just under the grid
which has the controls or to one side, in the dark grey, plain area. You'll
know you are in the right bit because it will say Form or Report (depending
which you are working on)in the Title Bar
the top of the Properties box.

Evi
 
F

Frankie Deschacht

Thanks for your help Evi.
(Still haven't found the right place to click, mind you).
But anyway,
A Merry Xmas and Happy New Year to you and everyone else in the group.
 
E

Evi

You're in report Design view.
*Make your window full size.*

You have clicked your Properties button.

You will see a grid with squares drawn on it and your report fields. That is
your report.

Just right of that, and also below it, is a plain grey area with no black
grid lines drawn on it. If your report is very large, you may need to
scroll to the side or down to see it.
Click on this.

Look at your Properties box.

Does it say Report at the very top of it, in the Title bar? If not, what
does it say?

Evi
 

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