how to stare image from a control in the ms/access db?

On my ms/access app I have an OLE field that must store images. The images are seen on an image control. The question is how do I move the picture in the image control to the OLE field?
João serras-pereiraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
You don't.   What you want to use is a bound OLE control.

 But actually you don't.   While Access has improved considerably in this area over past versions, it's still generally un-wise to store images in the DB.

 What's typically done is that you store the image on-disk and just keep a reference to the path in the DB.

 Then use the image control and set the path at run-time.

 While there are some reasons why you might want the image actually in the DB, those situations are usually rare.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Actually, looks like I'm behind the times a bit here...starting with A2007, you can set a control source on an image frame and tie it to a field in a table.

 I've never used that myself, but the suggestion to store on disk and only keep a path in the DB still stands.

 While an image control doesn't have the OLE overhead added to it, meaning you can only display static images with it (no editing of the object), you still don't want to add images to the DB, as the limit for DB size is 2GB.

 By storing a path only, you can work with far more images than if you stored them in the DB (of course if you have a back end other than an JET/ACE DB, that's a different story).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
João serras-pereiraAuthor Commented:
Hi Jim
Thanks for the help. I am using cxImage right now, which helps me on the image manipulation part. This is a small app to last for 3 years and a max of  800 images  for a physician (around 200K/image), yielding only 240 Mb of space (with overhead),  and putting it inside the DB makes very convenient for it's portability and "closeness" to competition.
Anyway it's working now with csXImage.
But I am really scratching my head on other parts and maybe I need further help...
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
If you really want to keep the data in the DB, there is also GetChunk() and AppendChunk() and in DAO.

 These allow you to read/write directly to OLE (BLOB) fields in Access.   When you need to work with the file, you write it out to disk, then use whatever tool you need to, then read it back in.

 So what you have is:

1. Unbound OLE control - Let's you work with OLE objects (pictures, word docs, spreadsheets, etc), but this is not tied to a field.
2. Bound OLE control - Let's you work with OLE objects (pictures, word docs, spreadsheets, etc), but this is tied to a field and the data is stored in the DB.  Access puts an OLE wrapper around the object.
3. Image control - Display of pictures only, may be stored in the DB with no OLE wrapper (Embedded) or on disk (Linked).
4. Use 3rd Party Controls like cxImage or DBPix.

Let me know what else you need.

João serras-pereiraAuthor Commented:
Thanks for the great help.
I decided, for the moment, to keep the images linked; I had no time available to debug all the problems that I was facing - so came back to your first suggestion; in the future, when time is possible, I'll migrate to getchunk/appendchunk.

Actually I bought both controls (DBPix and cxImage.

With DBPix, on my specific  development configuration, is losing the license, so I am sick and tired of, regularly, insert the license code again and again, and the cxImage provides much more functionality. It however comes with 2 problems: (i) in ms/access forms it actually modifies the control size to one of its own (sure a bug and Simon must be working on it) and (ii) somehow, when the image passes through the control and then goes to a standard image control (a thumbnail), is is shown in  with colours totally distorted and with strong artificial artefacts, making the image useless.

So I came back to strict standard image control (for the moment) and on the forms it is working, but not on reports, so I am launching a new question just for the reports.
Thanks again
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.