Home Access 2002 Images Use Pictures In Your Database   |   Search MS Office A-Z   |   Search Web Pages/ Design A-Z

Use Pictures In Your Database

When we think of databases, we usually visualize a bunch of grids filled with text and numbers. But an Access database can also include charts, graphs, movies, sounds, and, most notably, pictures. Sometimes images (which we’ll use interchangeably for pictures) are simply used for cosmetic purposes—to make forms and reports appear more attractive. In other cases, however, pictures provide important information that is an integral part of your database records.

Images can be either unbound or bound, and the choice often reflects whether the images are cosmetic or substantive. An unboundpicture doesn’t change from record to record. It’s therefore suitable for, say, a company logo; it’s a nice touch for a form or report, but it really doesn’t add any additional information.

In contrast, a bound picture is specific to an individual record. It’s used for employee records or product photos, obviously cases where the picture tells you as much as, or more than, any text field.

Let’s look at how each type works, starting with bound images.

 Images Stored In A Table

Open Northwind.mdb in the Samples subfolder of your Microsoft Office folder. Assuming you have made a copy (or have a backup) of the Northwind database, open the file. In the Database window, click Tables and double-click the Categories table to open it. Note that the last field in the table is Picture. Each of the records has the value Bitmap Image, a common type of picture file.

As you can see in the Category Name field, the first record is Beverages. Double-click Bitmap Image in the Beverages row. A picture of Beverages opens in a separate window. The next record is for Condiments. Double-click Bitmap Image in the Condiments row. A picture of Condiments is displayed. Close the image window.

If you were to double-click the other bit-map images, you would see that each corresponded to the specific product category. Even though each picture is different, in the table the value is always displayed as Bitmap Image. Because you cannot display an actual picture in datasheets, such as tables and queries, the value merely indicates the image file type.

Right-click any Bitmap Image value. Choose Insert Object. You’ll see two radio buttons: Create New and Create From File. The Create From File option lets you insert an image file that currently exists on your hard drive into the table.

Select the Create New radio button if it’s not already selected. In Object Type box, select Bitmap Image and click OK. You could draw a picture in this window, and Access would insert it into the table as a bit-map image. Close the window and close the table.

 Bound Images In A Form

In the Database window, Categories should still be selected on the Tables tab. Click the Insert menu and click Form. In the New Form dialog box, at the top choose AutoForm: Columnar; at bottom, the Categories table should be selected as the data source. Click OK to create the form. Maximize the form window.

The first record is Beverages. You should now see, in full view, the picture you saw when you double-clicked Bitmap Image for the Beverages record. At the bottom of the window, click the Next Record button to move to the next record, Condiments. As you can see, the picture changed to the corresponding category.

Click the View button to switch to Design View. Right-click the empty white box to the right of the Picture label and choose Properties. The title of the control is Bound Object Frame: Picture. The picture frame is bound because each picture is specific to each record.

Click the Data tab. The entry for the Control Source property is Picture. The source for the images is the Picture field in the Categories table. Even though the images are not visible in the table, that’s where they are stored.

 Unbound Image In A Form

Close the property sheet. The bound object frame should still be selected. Press Delete to delete the picture and the accompanying label. Click View to see that the picture and its label have disappeared. Click View again to return to design view.

Now let’s add an image to the form that is unbound. The image will remain the same as you move from record to record. For convenience’s sake, the image won’t be particularly appropriate to the form, but the procedure is correct.

Your toolbox should be in view. If not, click the View menu and then Toolbox. Click the Image button in the toolbox and drag the crosshair pointer four inches from the left and two rows of dots from the top. Click your mouse to open the Insert Picture dialog box. Open the Files Of Type drop-down menu and note the variety of graphics files that you can insert. Close the drop-down menu and leave the Graphic Files selection unchanged.

Navigate to the Samples subfolder of your Microsoft Office folder. Select the file Empid4.bmp. If you have any problem finding this file, feel free to insert any other graphics file, such as a BMP (bit map), GIF (Graphics Interchange Format), JPEG (Joint Photographic Experts Group), etc., that has dimensions of a few inches or less. Click OK.

Access inserts the file of one of Northwest’s employees. Click View. Press PAGE DOWN to scroll from record to record. Note that the picture remains the same regardless of the record.

Click View. Right-click the picture and select Properties. In the title bar, note that the frame is an Image. Click the Format tab. Click in the first property Picture and press your Right-arrow key to see the full entry. Although the bound picture frame had a field as its source, the source for this unbound image frame is a separate file on your hard drive.

You can close the form without saving the changes and exit Access.