Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing .jpg images in a table

Status
Not open for further replies.

rj51cxa

Technical User
Mar 16, 2006
216
GB
I have a small number of .jpg images (total about 1.2mb) that I would like to import into a table for use with a form which displays the appropriate photo for each record.

The reason for storing them in a table and not creating a link to another folder is that the database has to be a portable entity which is distributed to a number of different users. Once the photos are imported, that's it -there will be no more, other than updates.

I have found a proprietary database on the internet which actually does this, so I know it can be done. However, my knowledge of VB is not good enough to enable me to work out how they do it.

I have read all the threads about linking a form to a folder but I can find nothing relating to importing. I would be most grateful if someone could show me the way.

Best Regards
John
 
You can store pics in tables as OLE object data types and then link to them like normal on a form.
 
Thanks to both RivetHed and JoeAtWork.
I have tried storing the pics as OLE objects but it keeps asking me for the application associated with them. This is why I posed the question. RivetHed, if you can give me any more advice, I would be most grateful.
As far as the microsoft link from JoeAtWork is concerned, I will have to try it and respond when I have had a go.
Best Regards
John
 
Hi RevetHed
I had another go at importing a jpg photo into a table. I created a new table which had two fields - PhotoID (Autonumber)and Photo (OLE object). I then imported a jpg photo into the table which showed the photo as "Package". So far so good.
I then created a new form which had the two fields and tried to open the photo. All I got was text in the frame, giving the name of the photo. If double click on the frame, the photo opens in Picture viewer. not what I want at all.
I'm obviously missing something here and would be most grateful if you could advise how I go about displaying the photo in the form.
Thanks very much
John
 
If you try to use the "auto-magic" way (like the ridiculous example in Northwind database) your pictures will bloat the database (I found a 50K JPG took increased the database size by nearly 500K). Using the technique in the article is the only practical way I know of.

However, if you want to view the picture I believe you need to recreate the picture file, a good place would be in the user's temp directory.

I had a program that did exactly this, unfortunately the code is residing on the hard drive of a dissassembled computer right now.

 
Here is your issue:

Now if you are going to only store 1.2 mb of photos, I see no reason to use code to render the images. Yes your database will bloat by probably around 5-10 meg, but you got 2G before you have to worry.

However see thread705-1447753 for a class module that does some of this functionality.
 
John,

What sort of control are you using to display your picture on the form?
 
Thanks guys, I'll take a look tomorrow and respond - a bit busy tonight.
Best Regards
John
 
Hi RivetHed,

I'm using a bound object frame so that each photo is bound to the appropriate record.

Best Regards
John
 
MajP,
From what I can see, your code is designed for a picture that is stored outside the database. I'm afraid I cannot see how to modify it for an image that is stored in a table within the database.
I have created a form which has a bound object frame, so that each picture is associated with its own record. The problem, as I tried to explain before, is that all I see is the name of the picture e.g Duke of Westminster.jpg. The picture does not show until I click on it, then it opens in Picture Manager. I need it to open in the form itself.
Any ideas would be most welcome.
Best Regards
John
 
I've found one way of solving the problem. Microsoft suggest that you can get around the problem by re-installing Microsoft Photo Editor from Office XP or Office 2000. This re-establishes the OLE Server which was removed in Office 2003 when they replaced Photo Editor with Picture Manager.
I can now store the photos in a table without them appearing as a "Package" and can then display them in a Bound Object Frame. This solves the problem for me but may still create a problem if the database is viewed on a computer that is running Office 2003 but without Photo Editor.
Does anyone have any thoughts on how to get around this one?
Thanks to everyone who tried to help.
Best Regards
John
 
I think you need to reread the link I posted. If you see the word "Package" in your table then you will only see a link. If the word "bitmap image" or "microsoft word picture" appears then on the form the image will show up automatically. If the word "Package" appears you will get a icon. The article cover how to ensure the proper software is loaded to render the picture. You
 
disregard my last. I had that in the que and you did what the article suggests.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top