Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 6th, 2008, 03:07 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default The OLE object is empty

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


  #2 (permalink)  
Old June 20th, 2008, 07:05 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

I don't understand why you want to embed the Word document rather than just suppy the path and file name to Access and then use use Application.FollowHyperlink to open it. In that way,

1) Word fires up and opens the document.
2) The document is LINKED to the database, not embedded.
3) Embedded objects bloat the size of the database.
4) Once someone edits the Word document in the outside world, your embedded one (a copy?) is obsolete.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
  #3 (permalink)  
Old June 20th, 2008, 07:35 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can not do it the way you suggest. the embedded word files are technically nothing more than Large memo fields. Using an embedded word file gives the ability to format the text.

no external editing of the "Document" will take place. It only exists within the database. I don't care how large the database gets. Hard drive space is CHEAP.




  #4 (permalink)  
Old June 20th, 2008, 07:48 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Ah, a fancy memo field where you want rich text formatting. There are third party software that will let you do that to Access memo fields.

Although it is true that hard disk space is cheap, that's not the issue. The issue is that your MDB file will grow and grow... and after a certain size, it will actually become corrupt. You will run the risk of losing your entire database. Does someone out there know the upper limit?

Your hard disk may be very large, but MDBs are not programmed to hold multiple GBs of data.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
  #5 (permalink)  
Old June 20th, 2008, 07:59 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As of right now with a 7 year data set, I only have 400 records. I really don't think this size issue will be a problem. but thank you for pointing it out.



Similar Threads
Thread Thread Starter Forum Replies Last Post
embeding an OLE object ricespn Beginning VB 6 0 August 17th, 2007 12:47 AM
ole object insertion vinodkselpy Crystal Reports 0 March 1st, 2007 07:31 AM
OLE Object based on If statement lryckman Access VBA 3 October 25th, 2005 02:40 PM
OLE object in ASP MDrumm BOOK: Beginning ASP 3.0 3 June 18th, 2005 10:48 AM
OLE Object Type? j.gonsalves@ntlworld.com Access VBA 1 October 20th, 2004 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.