Creating a Table and a Form to Store Images

From NeoWiki

Revision as of 03:01, 18 October 2007 by Lorinda (Talk | contribs)
Jump to: navigation, search
This article is part of the To Base and Back Again tutorial series.

Suppose that our birder decided she or he wanted to also store pictures of particular birds in this database. It is possible for Base to store images, using the Image [LONGVARBINARY] field type. The tutorial below demostrates how to do that.

It should be noted, however, that storing large images and/or lots of images in an odb file can bloat the file to a very large size and create problems. Another approach is to store the locations of the image files in the database. That technique, however, goes beyond the scope of this tutorial--at least for the moment.

Contents

Create A New Table

  1. In the main database document window, click on the Tables icon in the left hand column.
  2. Double click on the Create Table in Design View icon in the Tasks section.
  3. In the Table Design window, create the following fields
    Pic_ID - Integer - Autovalue: Yes; Autoincrement Statement: IDENTITY
    DateTaken - Date - Entry Required: Yes; Format Example: as you desire I reccommend a YYYY format.
    BirdPictured - Text [VARCHAR] - Entry Required: Yes;
    Picture - Image [LONGVARBINARY] - Entry Required: Yes
    PicFieldTripID - Integer - AutoValue: No; Entry Required: No
    LinkToFile - Text [VARCHAR_IGNORECASE] - Entry required: No; Length: 500
    Note: The LinkToFile field is included on the assumption that the tutorial will eventually be expanded to cover turning a field's entry into a clickable hyperlink.
  4. You may also enter field descriptions if you like
  5. Control-click or right-click on the empy "cell" to the left of the Pic_ID field. Choose Primary Key from the contextual menu that appears.
  6. Click on the Save button on the toolbar (the disk drive image) or hit Command-S. Name the table Bird_Pictures.
  7. Close the Table Design window.

Note: Unlike other field types, images cannot be added directly to a table. Images can only be entered through a form.

Establishing Relationships

  1. In the main database document window, you should still have Tables selected in the left hand column. If not, click it.
  2. Go to the Tools menu and select Relationships.... The Relation Design window opens.
  3. Click on the Add Tables button on the toolbar. (The blue table)
  4. In the Add Tables window, select Bird_Pictures and click Add.
  5. Close the Add Tables window by clicking on the red circle in the upper right hand corner of the window.
  6. Resize the Bird_Pictures mini window so you can see all the fields.
  7. Drag the PicFieldTripID field in the Bird_Pictures table to the FieldTrip_ID field in the Field Trips table.
  8. Drag the EnglishName field in the AOU Birdlist table to the BirdPictured field in the Bird_Pictures.
  9. If desired, drag the table windows around so the relationship lines are easier to see.
  10. Click on the Save and close the Relation Design window.

Create The Data Entry Form

To create this form, we will invoke the wizard directly from the table. We are doing so here only to demonstrate the technique. The form can also be created in design view. (And, in point of fact, we will need to edit the form in order to use it to add images to the database).

  1. In the main database document window, you should still have Tables selected in the left hand column. If not, click it.
  2. Control-click or right-click on the Bird_Pictures table and choose Form Wizard from the contextual menu.
  3. In the Field Selection pane of the Form Wizard window, click the >> button to move all the fields over to the Fields in the Form column.
  4. Click Next>
  5. In the Subform pane, don't change anything. Just click Next>
  6. In the Arrange Controls section, choose an arrangement. I chose In Blocks-Labels Above, the option the furthest to the right.
  7. Click Next>
  8. Leave the Set data entry section settings as they are (This form is to display all data).
  9. Click Next>
  10. In the Apply Styles section, choose a color and field border style.
  11. Click Next>
  12. In the Set Name section, name the form Bird Pictures Data Entry and click on the Modify the form radio button
  13. Click Finish

Adding an Image Control

Entering Data

Personal tools