jpeg as long binary data

G

Guest

In a database I have there is a table that stores images as long binary data
type. How can I view the images in a form? Do I have to do some kind of
conversion before I can view them? I am stumped by this problem. Any help
(anything at all) is gratefully recieved
 
G

Guest

Have you tried the Bould Object Frame? This is usually used for Ole Object
fields.

Barry
 
G

Guest

That's what i thought but it doesn't work. I've scoured many forums looking
for hints but I'm not having much luck.
 
S

Stephen Lebans

The solution depends on how the original Images were inserted. It sounds
like it was simply a direct copy of a disk based Jpeg file into the Binary
field. To display the images, simply copy the contents of the field to a
temp disk file, then load this temp file into the Picture property of the
Image control.

I have posted code for this in the past but mainly for SQL Server solutions.
GoogleGroups search on my name and the relevant keywords to this issue.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Thanks Stephen. I have been reading your posts on this from Google and have
a vague idea of what needs to be done. I'm not sure why it was felt that the
pictures had to be put into access but I have to live with what others have
done.

Thanks for your help
 
G

Guest

When I try to copy the field content to a temp file i get an error saying "copy
isn't available now". How can I copy it to the file?
thanks
 
S

Stephen Lebans

I specifically instructed you to GoogleGroups search on this issue using my
last name as one of the Keywords. You would have found several threads
including:

From: Stephen Lebans - view profile
Date: Fri, Jun 17 2005 5:25 pm
Email: "Stephen Lebans"
<[email protected]>
Groups: comp.databases.ms-access,
microsoft.public.access.externaldata
Not yet ratedRating:
show options
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


It depends whether the App inserted the data as an OLE object or simply
as data in some format.

Create a form bound to this table. Add a BOUND Object Frame control
bound to the OLE field in question.


Now open the form in Form view. If you can see the data and interact
with it then you have an OLE object.
Otherwise you just have binary data in an unknow format. Perhaps it is
simply an actual copy of a file, say a JPG image, copied in its
entirety. In this case you would simply save off the field data to a
temp disk file. As long as you know the proper file extension for this
data your issue is solved.


FInally, it could simply be a blob of private data used by the App in an
unknow format. Heres some code to copy the contents of the current
record displayed in a Bound Object Frame control to a disk file. If this
temp file contains Text only then you can view it in Wordpad etc. If it
is a mixture of data types then you will need a HEX editor to view the
data. There are many freeware/shareware HEX editors on the Web.


Just add a CommandButton control to the form you created as per the
above instructions.


Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click


Dim a() As Byte
Dim lTemp As Long
Dim sl As String


lTemp = LenB(Me.olePicture.Value)
ReDim a(0 To lTemp) ' should be -1


' Copy the contents of the OLE field to our byte array
a = Me.olePicture.Value


sl = "OLEfieldTest" & ".dat"
Open sl For Binary Access Write As #1
Put #1, , a
Close #1


Exit_cmdSave_Click:
Exit Sub


Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click


End Sub



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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