code to load picture in OLEobject field?

G

Guest

Loading a picture into a table field can be done by hand:
- Open the Table with the OLE field inDatasheet view
- Right Click on the field and select "Insert object ..."
- Create from file
etcetera
(Some time ago "Stephen Lebans" answered a related question)

Now I would like to do something similar programmatically, but just can't
find the right syntax.
[ The reason to have pictures stored in the database is that they will be
very small icons held in a reference table containing categories of
the real (e.g. transactional) data. They have to show up in a continuous
form with the real data. The reference table should be easily maintainable. ]

Probably the answers are rather trivial to you, but what is the syntax to
get this done using:
1) DoCmd.RunSQL
or
2) OpenRecordset and rs.Edit ?

Thanks for any help
 
G

Guest

Analyst72 said:

Hi Analyst72,

I tried to follow that and came up with:

SQL = "SELECT * FROM category WHERE [category id]=" &
Str(CategoryID) & ";"
Set cat = CurrentDb.OpenRecordset(SQL, DB_OPEN_DYNASET)
cat.Edit
With cat![icon]
.Class = "Paint.Picture"
.OLETypeAllowed = acOLEEmbedded
.SourceDoc = FNam
.Action = acOLECreateEmbed
End With
cat.Update
cat.Close

This doesn't work while cat![icon] (being of data type "OLE Object") has no
..Class apparently.
Is the only way to get my job done by using controls of a form?
(I'm working with Access 2003)
 

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