Programmatically Store .bmp, .gif, .jpg in Access DB

R

Ray Jefferson

Hello all. I've been up and down and all around MSDN and I can't find what
I'm looking for. I'm trying to programmatically store a .bmp, .jpg, or .gif
file to an Access database and then be able to display that image in a Bound
Object Frame

If I use ADO and the Stream Object to try to do this, Access stores the file
as a Long Binary Object, which I can't view with the Bound Object Frame.

If I store the record with a SQL statement (DAO or ADO) without the image
field, the Bound Object Frame then complains there's no object and doesn't
allow for manually entry.

Setting the SourceDoc property to the file and then the Action property to
acOLECreateEmbed doesn't work either.

Anybody got a clue? This shouldn't be that difficult, yet its driving me
crazy.

Any and all help is appreciated.

Thanks,

RJ
 
P

PC Datasheet

Ray,

Use an image control to display images. Store the path to each image in a text
field in your table. Store the full path, for ex., C:\My Database\My
Images\Trees.bmp. Include this field on your form (not visible if you do not
need to enter the paths to the images).

Put thiscode in the OnCurrent event of your form:

Me!NameOfImageControl.Picture = Me!NameOfTextFieldContainingPath


--
PC Datasheet
A Resource for Access, Excel and Word Applications
(e-mail address removed)
www.pcdatasheet.com

· Design and basic development for new applications
· Additions, Modifications and "Fixes" for existing applications
· Mentoring for do-it-yourselfers who want guidance
· Complete application design and development
· Applications Using Palm Pilot To Collect Data And
Synchronize The Data Back To Access Or Excel
 
D

Dave

Ray,

I store images as follows. Really you want to load an image control from a
byte array in memory but I have not found a way to do that so I do this:

Create a long binary field in your table called eg "Image". You can read
the image files (.gif, .jpg) etc as binary into a byte array:

open filepath for binary as #1
redim ByteArray(lof(1))
get #1,1,ByteArray

then update the Image field in the table from the byte array.

You have stored the images.

To display, unfortunately you have to do the reverse, write the binary back
to a Temp file then do a LoadPicture from there. A bit naff but it works.
I would like a way to read the byte array from the table then load the image
directly but do not know how.

Method 2 would be to encrypt the images and store the paths to them as
suggested in the last post. You can use a quick and dirty encryption - you
do not need the "full monty".

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top