Displying OLE-content from rowsource

Tiger955

Registered User.
Local time
Today, 13:38
Joined
Sep 13, 2013
Messages
140
Hi,

I have two tables on a SQL-server 2008R2
tblProducts (fields: ProdID, Description, ProdImage,...)
where ProdImage is defined as varbinary(max)
tblProductsOnStock (fields: ID, ProdID, quantity, ...)

The tables from the server are linked to my Access 2010 front end.
In tblProducts the ProdImage is presented as an OLE-field
Now, on my form "frmProductsOnStock", based on tblProductsOnStock, I want to display the ProdImage from tblProducts.

The control Product is a combo-box and should hold ProdID, Description and ProdImage as column(2). But I cannot add an OLE-field to the rowsource of a combo-box.

How can I solve this or how can I display the ProdImage form the other table on this form?

Further what control should I use to disply the ProdImage?

Thanks your help.
Michael
 
This is the code I use to retrieve images from SQL Server. I place this in the OnCurrent event:

Code:
Dim rs As Recordset
Dim arrGIF() As Byte
Dim File1 As String

Set rs = CurrentDb.OpenRecordset("SELECT * FROM ImageTable WHERE ImageID = " & Me.ID, dbOpenDynaset, dbSeeChanges)

If Not rs.EOF Then
    If (Not IsNull(rs("Photo").Value)) Or (Len(rs("Photo").Value) <> 0) Then
        arrGIF = rs("Photo").Value
        File1 = Environ("TEMP") & "\temp.gif"
        Open File1 For Binary As #1
        Put #1, , arrGIF
        Close #1
        Me.imgMyImage.Picture = File1
        Kill File1
    End If
End If

You will need to modify the SQL string, the Photo field name from SQL Server, and the Image control name.

The control on your form should be an Image control.
 
Hi TJ,

sorry for very late reply due to holidays. I tried the code and it works. Due to the fact that the design of the products change, I changed my concept as well and have to copy the picture to each record anyhow, which makes it easier to present the image anyhow.

But thanks again.
Michael
 

Users who are viewing this thread

Back
Top Bottom