Embedding images from form to table

G

Guest

Could someone please help me with this as I've been going round in cricles
for days getting nowhere.
I have a form in which people enter data in to a couple of txt fields and
also an option to load an image. I then use the following code to save the
data to a table -

Private Sub cmdAdd_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEquipment", dbOpenDynaset)
With rst
.AddNew
![Model] = Me.txtModel
![Description] = Me.txtDescription
![Reference] = Me.txtReference
![Serial] = Me.txtSerial
![Image] = Me.imgPicture.Picture
.Update
End With
rst.Close
Set dbs = Nothing
End Sub

The problem is that the Image field on the table says 'Long Binary Data'
instead of 'Bitmap Image' and I am unable to view the image.
Thnks in advance.
 
G

Guest

You would be much better storing the image outside of access and use that
field to save the directory and name of the image, and then use that to
choose the image to display.
However if the back end is Access tables then select OLE Object as data
type, although I'm guessing it isn't by the long BINARY datatype.

TonyT..
 
G

Guest

Thanks for the response. I'm begining to think linking is the easier option
but can see that being a problem when someone desides to clean up the drive
and delete all the pics (which happens a lot). So for this reason I would
like to be able to embed the images.
I didn't understand your last sentence!

TonyT said:
You would be much better storing the image outside of access and use that
field to save the directory and name of the image, and then use that to
choose the image to display.
However if the back end is Access tables then select OLE Object as data
type, although I'm guessing it isn't by the long BINARY datatype.

TonyT..

Finks said:
Could someone please help me with this as I've been going round in cricles
for days getting nowhere.
I have a form in which people enter data in to a couple of txt fields and
also an option to load an image. I then use the following code to save the
data to a table -

Private Sub cmdAdd_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEquipment", dbOpenDynaset)
With rst
.AddNew
![Model] = Me.txtModel
![Description] = Me.txtDescription
![Reference] = Me.txtReference
![Serial] = Me.txtSerial
![Image] = Me.imgPicture.Picture
.Update
End With
rst.Close
Set dbs = Nothing
End Sub

The problem is that the Image field on the table says 'Long Binary Data'
instead of 'Bitmap Image' and I am unable to view the image.
Thnks in advance.
 
G

Guest

You can set the folders and image files to hidden and still get to access them.

My second sentence was basically asking you if you are trying to store the
image in an Access table (and if so which version) and to say that if you
look at that table in design view, the field for the images to be stored in
should be set to a data type of OLE Object, which will accept images.

TonyT..

Finks said:
Thanks for the response. I'm begining to think linking is the easier option
but can see that being a problem when someone desides to clean up the drive
and delete all the pics (which happens a lot). So for this reason I would
like to be able to embed the images.
I didn't understand your last sentence!

TonyT said:
You would be much better storing the image outside of access and use that
field to save the directory and name of the image, and then use that to
choose the image to display.
However if the back end is Access tables then select OLE Object as data
type, although I'm guessing it isn't by the long BINARY datatype.

TonyT..

Finks said:
Could someone please help me with this as I've been going round in cricles
for days getting nowhere.
I have a form in which people enter data in to a couple of txt fields and
also an option to load an image. I then use the following code to save the
data to a table -

Private Sub cmdAdd_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEquipment", dbOpenDynaset)
With rst
.AddNew
![Model] = Me.txtModel
![Description] = Me.txtDescription
![Reference] = Me.txtReference
![Serial] = Me.txtSerial
![Image] = Me.imgPicture.Picture
.Update
End With
rst.Close
Set dbs = Nothing
End Sub

The problem is that the Image field on the table says 'Long Binary Data'
instead of 'Bitmap Image' and I am unable to view the image.
Thnks in advance.
 
G

Guest

I could try that but it's a network drive and the admins get funny about (and
delete) images being stored on it.

It's 2003 SP2 and I've set the table field for the images as an OLE Object
already

TonyT said:
You can set the folders and image files to hidden and still get to access them.

My second sentence was basically asking you if you are trying to store the
image in an Access table (and if so which version) and to say that if you
look at that table in design view, the field for the images to be stored in
should be set to a data type of OLE Object, which will accept images.

TonyT..

Finks said:
Thanks for the response. I'm begining to think linking is the easier option
but can see that being a problem when someone desides to clean up the drive
and delete all the pics (which happens a lot). So for this reason I would
like to be able to embed the images.
I didn't understand your last sentence!

TonyT said:
You would be much better storing the image outside of access and use that
field to save the directory and name of the image, and then use that to
choose the image to display.
However if the back end is Access tables then select OLE Object as data
type, although I'm guessing it isn't by the long BINARY datatype.

TonyT..

:

Could someone please help me with this as I've been going round in cricles
for days getting nowhere.
I have a form in which people enter data in to a couple of txt fields and
also an option to load an image. I then use the following code to save the
data to a table -

Private Sub cmdAdd_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEquipment", dbOpenDynaset)
With rst
.AddNew
![Model] = Me.txtModel
![Description] = Me.txtDescription
![Reference] = Me.txtReference
![Serial] = Me.txtSerial
![Image] = Me.imgPicture.Picture
.Update
End With
rst.Close
Set dbs = Nothing
End Sub

The problem is that the Image field on the table says 'Long Binary Data'
instead of 'Bitmap Image' and I am unable to view the image.
Thnks in advance.
 
G

Guest

A quick read of;

http://support.microsoft.com/default.aspx?scid=KB;EN-US;205635

found that you should be using;

Image.CreateEmbed = me.imgPicture.Picture

because;

The advantage of using this technique is that the data is stored in the
Access OLE Object format. Thus, a user who opens the database in Access and
double-clicks on the item will find that the appropriate container for the
data is automatically started. If you place the data into a field without
using of the below-mentioned method, it is stored as "Long Binary" data in
Access, and the appropriate container for the data is not started when a user
double-clicks the item in Access.

Hope this helps,

TonyT..

Finks said:
I could try that but it's a network drive and the admins get funny about (and
delete) images being stored on it.

It's 2003 SP2 and I've set the table field for the images as an OLE Object
already

TonyT said:
You can set the folders and image files to hidden and still get to access them.

My second sentence was basically asking you if you are trying to store the
image in an Access table (and if so which version) and to say that if you
look at that table in design view, the field for the images to be stored in
should be set to a data type of OLE Object, which will accept images.

TonyT..

Finks said:
Thanks for the response. I'm begining to think linking is the easier option
but can see that being a problem when someone desides to clean up the drive
and delete all the pics (which happens a lot). So for this reason I would
like to be able to embed the images.
I didn't understand your last sentence!

:

You would be much better storing the image outside of access and use that
field to save the directory and name of the image, and then use that to
choose the image to display.
However if the back end is Access tables then select OLE Object as data
type, although I'm guessing it isn't by the long BINARY datatype.

TonyT..

:

Could someone please help me with this as I've been going round in cricles
for days getting nowhere.
I have a form in which people enter data in to a couple of txt fields and
also an option to load an image. I then use the following code to save the
data to a table -

Private Sub cmdAdd_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEquipment", dbOpenDynaset)
With rst
.AddNew
![Model] = Me.txtModel
![Description] = Me.txtDescription
![Reference] = Me.txtReference
![Serial] = Me.txtSerial
![Image] = Me.imgPicture.Picture
.Update
End With
rst.Close
Set dbs = Nothing
End Sub

The problem is that the Image field on the table says 'Long Binary Data'
instead of 'Bitmap Image' and I am unable to view the image.
Thnks in advance.
 

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