6 Pictures
Up
It would be nice if we could incorporate photos into our database and display them in the 'CustomerDataEntry' form that you made in lesson 3. Access uses OLE to incorporate pictures (or sounds, or many other types of file) into Access - you recall from previous work that OLE stands for 'Object Linking and Embedding'. So this lesson is in two stages:
  1. Embed images into our Customer table as OLE objects.
  2. Add a frame to our CustomerDataEntry form and arrange for the images to display in the frame.

1. Embed images into the Customer table

First you will need to find suitable photos of our four customers, so why not copy these photos into your folder (right-click each one and choose 'Save Image As...'):

Mr. Smith:

 

Mrs. Jones:

 

I'll leave it to you to find pictures of the other customers on the internet. They'll probably be the wrong size compared to these so why not resize them in Paint Shop Pro to about 128 x 170 pixels - it'll be good practice for you.

Now you'll have to add a new field to your Customer table. Call the new field Photo and set its type to be OLE object. You recall that OLE stands for 'Object Linking and Embedding' so you will have to choose whether you want to EMBED the photos in the database, so that they become part of the database file, or link to the photo files, so that they remain separate. Perhaps it's better to embed them for with linked files there is always the risk that the link will fail if the files are renamed, moved or deleted.

To embed a photo in the database, open the Customer table in datasheet view (as opposed to design view) and click on the cell that will contain Mr. Smith's photo (in the Photo field). Now choose Insert>Object (the Object option is only available if the field has been configured with OLE Object as its type). The next step depends on whether you are working at EE3, where the OLE component is not correctly installed (as of October 2006), or elsewhere - do ONLY ONE of the following two steps:

If you are in EE3 then do this:

Choose 'Create New' and 'Bitmap Image'. This should open the Paint program. In the Paint Program choose 'Edit>Paste From...' and navigate to one of the photos you saved. Once you have pasted the image into the Paint window, close the Paint Program and you should see that the words 'Bitmap Image' appear in the cell into which we pasted the picture (double-clicking the cell will reopen the image in Paint). Note that the image cannot be displayed in the table but it can be displayed in a form, query or report... Don't forget to skip the next paragraph if you are in EE3.

If you are not in EE3 then do this:

Choose 'Create from file' and then browse to the picture file that you downloaded. When you click OK the picture will be embedded in the database but you won't see it displayed in the table for tables are incapable of displaying pictures - instead you will see the phrase 'Editor 3.0 Photo' or similar. Try double-clicking the cell and the picture should open in the associated program (Microsoft Photo Editor, in this case). Then close the photo editing program.

2. Add a frame to the CustomerDataEntry form

Open the CustomerDataEntry form, the one that looks like this:

 

Switch to design view and widen the form as shown (notice the shape the mouse pointer has taken). Now make sure the Field List icon is selected in the Toolbar so that the Field List is visible - it should look like this:

Drag the 'Photo' field from the Field List window onto the form and you should see something like this:

We see that we have just placed a label marked 'Photo' onto the form and a 'frame' that will hold our photo (you can see the 8 black handles around the frame). The frame is rather too big for our small photos so pull the bottom-right corner handle until the frame has about the right size and shape to accept our photo format. We don't really need the label 'Photo' so click the label and delete it. You may get the impression you just deleted the frame too but if you click again where the frame was you will see it is still there. Now when you switch back to form view you should see something like this:

When you use the navigation bar at the bottom of the form you should be able to Mrs. Jones and the other photos that you embedded, too. Pictures like this that change according to which record is selected are called BOUND objects - it's also possible to put pictures on the form that are always the same no matter which record is selected - such pictures are said to be UNBOUND.

Summary

In this tutorial, we have covered the basics for creating an Access database including tables with data, queries to retrieve data, forms to enter data and reports to display and summarize data. We've also learnt how to use OLE (Object linking and Embedding) to embed images into our database file, and we have modified our form so that it displays the images correctly.

Going further

Students are encouraged to further their Access knowledge and skills by working through more advanced tutorials and by reading the on-line help and Access documentation.

Now that you have done some work with a simple database you may want to take a look at a more sophisticated one. The Northwind Traders database is the standard training database included with MS Access but only download instructions are given here - you can learn something about databases by examining the structure of this database but if you want a tutorial that analyses it in detail you will have to search the internet...

To download the Northwind Traders database, go to the Microsoft website at www.microsoft.com and do a search there for Northwind...

Previous Up Next