Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Using VB code to link an "OLE Object" field to a bitmap file


Message #1 by peterfrb2@y... on Mon, 27 May 2002 06:19:15
Hello:

I have a directory containing over one-hundred bitmap files, and I'd like 
to construct a table in Access that contains an "OLE Object" field and 
assign the OLE field, one by one, to the corresponding file.  

In my particular case, each bitmap is a screenshot of a test question, and 
they're all numbered.  I was planning to use a DAO record object to 
implement the insertion, and the following is a skeletal view of the code 
I was planning to write:

    Set MyRcd = CurrentDb.OpenRecordset("Quizes", dbOpenDynaset)
    For iCount = 1 to 100
        MyRcd.AddNew
        MyRcd("Image") = [Wrapper code] MyDir & "\Question_" & iCount & _
            ".bmp"
        MyRcd.Update
    Next iCount

My directory, defined as string "MyDir", contains each question of my quiz 
in its own bitmap file, in the 
form "Question_1.bmp", "Question_2.bmp", "Question_3.bmp", etc.  I could 
implement this the long way, by manually inserting the proper bitmap into 
one-hundred successive rows, but I wish to have code perform this labor-
intensive task.  My question is, what "wrapper" code do I need to 
accomplish the feat?

Also, is there another way to accomplish the same goal?  Could I, for 
example, write an Append Query such that I have a wrapper around the file 
path to which the OLE field will point?

Sincerely,
Peter Ferber

  Return to Index