Solved

Insert OLE object into Access database via VB

Posted on 2010-08-13
10
1,723 Views
Last Modified: 2013-12-25
Hi,

I follow the following article:

http://support.microsoft.com/kb/210486

to insert a JPEG file to a OLE field.

However, when I try to open the OLE field by double-clicking the field, I get the following error message(attached in this question).

Please help!




error.jpg
0
Comment
Question by:chcw
  • 5
  • 4
10 Comments
 
LVL 4

Expert Comment

by:stevepicks
Comment Utility
maybe you need to install
 Microsoft Photo Editor
see more at
http://support.microsoft.com/default.aspx?scid=kb;en-us;832508&Product=a

However it would be better-faster for your data, not to store the images inside the table as OLE objects, you can store the image as file paths and uplod them to your server and later present them from their paths.
0
 
LVL 8

Author Comment

by:chcw
Comment Utility
I am testing a database with OLE object field, so I have to use OLE field to store objects, instead of just storing the file path.
0
 
LVL 44

Expert Comment

by:Leigh Purvis
Comment Utility
Hi
I'm afraid you're combining incompatible methodologies.
The MS article you highlight is for the insertion (and extraction) of BLOB data from an OLE field. This is a comparatively manual process (in that you're handling the data operations in code - rather than relying on Access functionality).
You can't then switch, and double click the field to have Access launch it as if it were an Access inserted OLE object.
(Hence the error message).
It's a bunch of BLOB data without the binary padding that Access inserts to allow it to use it natively upon demand (and maintain a thumbnail of the file for onscreen representation).

Use the other function on that page to extract the file again to your HD (albeit temporarily perhaps) and launch that file.
(There's a BLOB demo in the examples page linked to in my profile).
Alternatively revert back to the (bloated) method of OLE object insertion.
http://support.microsoft.com/kb/114214
Don't forget to consider the advice from stevepicks regarding storing only links to the original file. (Or a copy of it - whatever is required.)
Cheers,
0
 
LVL 8

Author Comment

by:chcw
Comment Utility
Hi,

I checked http://support.microsoft.com/kb/114214, but it is only used to link an object in the form. If I do not have a visible form but only want to insert an external file as an OLE which can be opened by double-clicking it, then how to do so?

Thanks

0
 
LVL 44

Expert Comment

by:Leigh Purvis
Comment Utility
There are two examples on that page. One linking, the other for embedding.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Author Comment

by:chcw
Comment Utility
I checked it, it only works for object frame in Access(I don't know what is an object frame). But I need to use Visual Basic to insert the OLE object directly via DAO or other data engines, not via Access or VBA.
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 500 total points
Comment Utility
Yeah... if you're wanting to insert Access OLE Objects in VB then you're out of luck.
It would require knowing the exact binary wrapping that Access inserts around the BLOB data of the object itself.
You need the Access control.
It's entirely Access specific functionality.
If you're doing this in VB then use an third party image tool, or work with BLOBs as you were earlier. (But you'll have to manually code the extraction of the BLOB when you double click your picture control.)
0
 
LVL 8

Author Comment

by:chcw
Comment Utility
Is it possible to insert a word document or Excel spreadsheet with the BLOB method via VB and I can double-click to load the embeded object?
0
 
LVL 44

Expert Comment

by:Leigh Purvis
Comment Utility
The double click would be just running your own manual code though - yeah?
You're not in Access (you're in VB) and so the OLE Object control isn't there to help you out.
So it's all your own code.
But yes, you can insert any file type as a BLOB.
Cheers.
0
 
LVL 8

Author Closing Comment

by:chcw
Comment Utility
Thanks
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now