Question : Automatically embed Word document in Access OLE Object field

I have a field in a MS Access table that is set up as an OLE Object.  When I create a new record using the navigation bar, I would like the field to automatically have an embedded Word document.

Here's how to do it manually...
If I right click on the new record's field, I go to "Insert Object" on the context menu and then "Create New", "Object Type: Microsoft Word Document".

How do I do this with VBA?

Answer : Automatically embed Word document in Access OLE Object field

Just detect if it's null or not:

Private Sub OLE1_Enter()
 If IsNull(OLE1) Then 'create new document
   OLE1.Class = "Word.Application"
   OLE1.Action = acOLECreateEmbed
 End If
End Sub

Random Solutions  
 
programming4us programming4us