saving OLE-objects!!

tomro1

Registered User.
Local time
Today, 02:26
Joined
Jun 12, 2006
Messages
23
Hi all,

I have made a table like this:
TBLpictures
ID
FLDpath - memo
FLDname - text
FLDpicture - OLE object

now, what I need to do is to make a button that, when I click on it, it looks in a folder "c:\\Pictures" and puts all the pictures into the table.

But I'm stuck at the part where I want to save the OLE-object.

this is my code so far

Code:
Private Sub cmdupdate_Click()
    Dim fs, f, f1, fc, s
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim SQLQ As String
    SQLQ = "SELECT * FROM tblpictures;"
    Set db = CurrentDb
    Set rs = db.OpenRecordset(SQLQ, dbOpenDynaset)
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("C:\\pictures")
    Set fc = f.files
    For Each f1 In fc
    
        s = f1.Name
        rs.AddNew
        rs!FLDname= s
        rs!FLDpath= "C:\\pictures" & "\" & s
        rs!FLDpicture=???????????

        rs.Update
        rs.MoveLast
    Next
    MsgBox "finished"

End Sub

so does anyone know what I have to do to put in my pictures? plz help
 
Last edited:
I don't know what you mean by "and puts all the pictures into the folder".
A mass output - you'd look here.
(AFAIK Stephen's the only one to have disected the binary storage of the OLE datatype - as Access wraps a load of kak around the file data itself).

IMO if you're wanting a lot of control over the files in a database then using the default OLE functionality is not the way to go about it.
Access 2007's attachment datatype is very good - but perhaps not available to what you're using. BLOBs would be the standard alternative (but be advised that they don't offer any native viewing of the file from within the database - e.g. thumbnails etc).
 
Well, what I want to make is a continous form where I can view all my pictures that are in a folder.
But, the program also has to put the pictures, form in the folder, into the table, so also into the OLE column.

How can I make this?
 
Right. Is that all you're wanting to do though - see the pictures in the folder?
If so then loading them into a table would seem very wasteful resource and disk (/filesize) wise.
You could same some size by linking them - but that's not particularly efficient in an OLE wrapped container either.
Assigning the image properties directly won't help you (in a continuous form) unless you're using Access 2007 anyway (which brilliantly - and finally - allows runtime bound image paths).
If you're having to use a version prior to 2007 (and your aim really is to only display the images) you could perhaps just emulate a continuous form - with a set of image controls on the form - filling each of their sources in code and providing navigation buttons Next and Back to fetch the next lot of images.
(Just to rule them out, BLOBs will not help you in this scenario - for the reason as I indicated earlier).
 
Ok, that just sucks..

But thanks anyway! Think I'm going to check out 2007
 
I'm not really sure what entirely sucks - in that displaying file images (that aren't stored) in a continuous form isn't really what a database application is about. If you're going to store them - then there's an overhead in doing the insert and in the substantial diskspace they'll consume in the database.

Emulating a subform wouldn't be that much of a hassle. If you really wanted you could use an ActiveX scrollbar to make it feel just the same.

But if Access 2007 is a viable option for you then it's going to be very simple there.
 

Users who are viewing this thread

Back
Top Bottom