ACC2: Cannot Embed OLE Objects Using Access Basic Code

Last reviewed: June 8, 1997
Article ID: Q120262
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

You can use Access Basic code to embed one OLE object in a bound control on a form successfully. However, subsequent OLE objects that you try to embed with Access Basic code are visible in the form, but are not saved when you save the record.

CAUSE

You are not moving the focus in your Access Basic code to the OLE controls in which you are trying to embed objects.

RESOLUTION

Set the focus in your Access Basic code to subsequent OLE controls before saving the record.

STATUS

This problem no longer occurs in Microsoft Access version 7.0.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new table with two OLE object fields called OLE1 and OLE2. Set the Required property for both fields to Yes.

  2. Create a new form based on the table you created in step 1. Add the two OLE fields to the form.

  3. Set the form's OnLoad property to the following event procedure:

          Sub Form1_Load
             Me![OLE1].SourceDoc = "c:\windows\arcade.bmp"
             Me![OLE1].Action = OLE_CREATE_EMBED
    
             Me![OLE2].SourceDoc = "c:\windows\arcade.bmp"
             Me![OLE2].Action = OLE_CREATE_EMBED
          End Sub
    
    

  4. View the form in Form view. Note that both the OLE controls contain the Arcade bitmap.

  5. From the File menu, choose Save Record to save the record. You will receive the error message:

          Field '<tablename>.OLE2' can't contain a null value
    

    NOTE: If you did not set the Required property for both fields to Yes, you will not receive an error message, and the second OLE object field will contain a null value.

To correct the problem, change the event procedure for the OnLoad property as follows:

   Sub Form1_Load
      Me![OLE1].SourceDoc = "c:\windows\arcade.bmp"
      Me![OLE1].Action = OLE_CREATE_EMBED

      Me![OLE2].SourceDoc = "c:\windows\arcade.bmp"
      Me![OLE2].Action = OLE_CREATE_EMBED
      Me![OLE2].Setfocus
   End Sub

REFERENCES

Microsoft Access "User's Guide," version 2.0, Chapter 19, "Using Pictures, Graphs, and Other Objects," pages 470-481

Microsoft Access "Building Applications," version 2.0, Chapter 4, "Adding and Editing Data," pages 64-65


Additional query words: link
Keywords : kberrmsg kbole kbprg PgmOthr
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.