Lesson11.9.Using OLE Object Fields


Lesson 11.9. Using OLE Object Fields

Figure 11-15. The Insert Object dialog box


Figure 11-16. The Insert Object dialog box with the Create from File option selected.


Figure 11-17. In Datasheet view you normally can't see the actual OLE objects.


Figure 11-18. The inserted photo displayed in the frmEmployees form.


Perhaps the least understood of all , the OLE Object data type lets you store files created in other programs such as graphics, Excel spreadsheets, or Word documents. This lesson will give you some practice working with OLE object fields.

  1. Select the tblEmployees table and click the Design button.

    First we need to add an OLE field to this table.

  2. Click the first blank Field Name row and type Photo. Click the Data Type list arrow and select OLE Object from the list.

    You've created an OLE Object field!

  3. Save your changes and then click the View button on the toolbar to display the table in Datasheet view.

    Let's try adding an OLE object to the Maria Wyatt record.

  4. Click in any field for Maria Wyatt, scroll to the right, click in the Photo field for the Maria Wyatt record (using the record selector as a guide), and select Insert The Insert Object dialog box appears, as shown in Figure 11-15. You can create and then insert new objects by selecting the Create New option or you can click the Create from File option to insert an existing file. For this exercise, we already created and saved a photo, so you need to select the Create from File option.

  5. Click the Create from File option.

    The Insert Object dialog box displays the Create from File options, as shown in Figure 11-16. Here you will specify the name and location of the file you want to insert.

  6. Click the Browse button.

    Now you need to find and locate the file you want to insert into your document.

  7. Browse to your Practice folder, then find and double-click the Maria.bmp file.

    The name and location of the Maria.bmp file appears in the File box. Before we close the Insert Object dialog box, there is one more very important option we need to explorethe "Link" check box. The "Link" check box determines whether the OLE object is actually embedded within the database or merely linked to it. This is a rather difficult concept for most peopleyou might want to look at Table 11-2 for more on the differences between the two.

    For this exercise, we want to embed the graphic within the database, so we'll leave the Link box unchecked.

  8. Click OK.

    The dialog box closes, and Access embeds the Maria.bmp picture in the Photo field.

    The problem with working with OLE object fields in Datasheet view is that you can't see the actual OLE objects (see Figure 11-17). It's for this reason that you may want to use a form to work with OLE object fields.

  9. Close the tblEmployees table. Click the Forms icon in the Objects bar, click the frmEmployees form, and click the Design button.

    First we need to add the new photo field to the form.

  10. Click the Field List button on the toolbar, if necessary. Click and drag the Photo field anywhere on the form.


    Tip: Another way to display the field list is to select View

    Don't worry about where you place the Photo OLE object field or if it covers other fieldswe're not striving for perfection here. As with any other form control, you can move and resize OLE object fields.

    Let's see how the Photo field looks in Form view.

  11. Click the View button on the toolbar to switch to Form view. Click the Next Record Navigation button until you find the record for Maria.

    Yep! There's the picture! (See Figure 11-18.)

  12. Close the frmEmployees form without saving any changes.

Table 11-2. Embedded vs. Linked Objects

Object Type

Description

Embedded (Link box not checked)

An embedded object is actually saved within the database. Databases with embedded objects are larger than databases with linked objects. The advantage of using embedded objects is that the objects are actually saved inside the database, so you don't have to worry about any attached files becoming lost or erased.

Linked (Link box checked)

A linked object is not saved in the database. Instead, a link contains information on where to find the source data file. The advantage of using linked objects is that if the source file is changed, the linked object in the database is automatically updated to reflect the changes.


QUICK REFERENCE

TO CREATE AN OLE OBJECT FIELD:

  1. DISPLAY THE TABLE IN DESIGN VIEW.

  2. CREATE A NEW FIELD TO STORE THE OLE OBJECTS.

  3. CLICK THE NEW OLE FIELD'S DATA TYPE BOX, CLICK THE LIST ARROW, AND SELECT OLE OBJECT.

  4. SAVE THE TABLE.

TO INSERT AN OLE OBJECT:

  1. SELECT THE OLE OBJECT FIELD AND SELECT INSERT

    SELECT EITHER:

    CREATE NEW:TO CREATE A NEW OLE OBJECT FILE (YOU MUST SELECT THE TYPE OF FILE YOU WISH TO CREATE).

    CREATE FROM FILE: TO INSERT AN EXISTING FILE.

  2. CLICK OK.

  3. IF YOU SELECTED THE CREATE FROM FILE OPTION, BROWSE TO AND DOUBLE-CLICK THE FILE YOU WANT TO INSERT AND CLICK OK.




CustomGuide Inc - Access 2003 Personal Trainer
Access 2003 Personal Trainer (Personal Trainer (OReilly))
ISBN: 0596009372
EAN: 2147483647
Year: 2005
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net