The OLE object is empty

Lee Weaver

Registered User.
Local time
Today, 10:58
Joined
Jun 6, 2008
Messages
20
I am new to VBA for access. I have done a small VBA project with excel but this my first attempt to do anything with access.

I'm getting "The OLE object is empty" and I understand why. what I want to do is avoid this by automatically creating a word document and embedding it in the field in question when a user starts entering a new record. What I have found sugests that I use _beforeinsert but I can not seem to figure out how to do it. It may be that I am just placing the code in the wrong place.

this is the code I have found and tried to modify to use.
_________________________________________________________-
Option Compare Database


Private Sub tfirrdata_BeforeInsert(cancel As Integer)
' Specify what kind of object can appear in the field.
block18a.Class = "Word.Document"

' Specify what kind of object can appear in the field.
block18a.OLETypeAllowed = OLE_EMBEDDED

' Create the embedded object.
block18a.Action = OLE_CREATE_EMBED

' Invoke Word for Windows to edit the empty embedded object.
block18a.Action = OLE_ACTIVATE

End Sub
__________________________________________________________


The problem is this never fires.

the form in question is named "tfirrdata"

the field i want to embed the word document into is "block18b"

with excel it's fairly easy to figure out where your code needs to go... but access isn't quite so simple.

Lee G. Weaver
 
So you're saying that you want to embed a Word document in a record (?) right when that record has been added to the database?

I would think you would want the OLE object embedded long before you've edited the record and said to save it to the database. Perhaps you should be looking at "On Current" instead.
 
yes you seem to understand what i need

I need to embed the empty word document in the record when the user starts to add the record. so when they get to that field it's already set up as a word document to type in.

Lee G. Weaver
 
OK, do what I said: use "On Current" and put your code which you posted in there instead of in the "Before Insert" event.

BTW, I'm trusting you on the rest of it...I have no idea if this will work as presented.

And cheer up, everything is solvable.
 

Users who are viewing this thread

Back
Top Bottom