Question : Load picture into image using a recordset

I am trying to figure out how to load an image into a bound object frame by using a recordset.  The image is stored in an OLE field in a table that is not part of the recordsource of the form.  Here is the code that I have so far:

**********************************
Dim dbs As Database
Dim RS As Recordset
Dim ImageSQL As String

Set dbs = CurrentDb()
ImageSQL = "SELECT tblImages.Image FROM tblImages"
ImageSQL = ImageSQL & " WHERE (((tblImages.[#])=5));"

Set RS = dbs.OpenRecordset(ImageSQL)

' I don't know what code to use to assign the picture identified by ImageSQL into Image1
'Me.Image1 = RS.Fields(0)   ????????????
'Me.Image1.ControlSource = RS.Fields(0)  ???????????
'Me.Image1.ControlSource = "Image"  ?????????????


How do I assign the image to the picture ?

Thank you.

Answer : Load picture into image using a recordset

try this, and avoid using special characters as fieldname or part of fieldnames change # to ImgNum or anything else


ImageSQL = "SELECT ImgNum, Image FROM tblImages"
ImageSQL = ImageSQL & " WHERE (((tblImages.ImgNum=5));"

in this SQL  RS.Fields(0)  will be ImgNumber
                 RS.Fields(1) will be Image

Random Solutions  
 
programming4us programming4us