Solved

Insert OLE object into Access database via VB

Posted on 2010-08-13
10
1,769 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
ID: 33427548
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
ID: 33427582
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
ID: 33437493
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 8

Author Comment

by:chcw
ID: 33442757
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
ID: 33445550
There are two examples on that page. One linking, the other for embedding.
0
 
LVL 8

Author Comment

by:chcw
ID: 33460541
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
ID: 33463151
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
ID: 33464920
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
ID: 33465214
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
ID: 33583023
Thanks
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

832 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