ACC2: Cannot Embed OLE Objects Using Access Basic Code
ID: Q120262
|
The information in this article applies to:
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
- Create a new table with two OLE object fields called OLE1 and OLE2.
Set the Required property for both fields to Yes.
- Create a new form based on the table you created in step 1. Add the
two OLE fields to the form.
- 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
- View the form in Form view. Note that both the OLE controls contain
the Arcade bitmap.
- 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
Version : 2.0
Platform : WINDOWS
Issue type : kbbug