The code below should help you. Some of it is off the top of my head so
might need tweaking.
It takes an Icon file stored in a table, and extracts it to a temporary file
(the file name and path are obtained using the GetTempPath and
GetTempFileName windows APIs and the temp file is deleted after use using
the DeleteFile API , but you can hard code the filepath/name if you want).
Public Sub LoadCustomIcon
On Error GoTo Err_LoadCustomIcon
Dim IconData() As Byte
Dim lngNo As Long
Dim intNo As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTempDir As String
Dim strTempFile As String
strTempDir = String(255, Chr$(0))
GetTempPath 255, strTempDir
strTempDir = Left$(strTempDir, InStr(strTempDir, Chr$(0)) - 1)
strTempFile = String(255, 0)
GetTempFileName strTempDir, 0, 0, strTempFile
strTempFile = Left$(strTempFile, InStr(1, strTempFile, Chr$(0)) - 1)
Set db = CurrentDb
Set rs = db.OpenRecordset("YourTable", dbOpenDynaset)
rs.FindFirst "[IDField]='" & ID & "'"
'Not totally sure if this is the right syntax - may need tweaking
lngNo = LenB(rs!OLEField)
ReDim IconData(lngNo - 1)
IconData = rs!OLEField
intNo = FreeFile
On Error Resume Next
Open strTempFile For Binary Access Write Lock Write As intNo
Put #intNo, , IconData()
Close #intNo
On Error GoTo Err_LoadCustomIcon
'**************************
'Do what you want here
'**************************
Call DeleteFile(strTempFile)
Exit_LoadCustomIcon:
Set rs= Nothing
Set db = Nothing
Erase IconData
Exit Function
Err_LoadCustomIcon:
MsgBox Err.Number & ": " & Err.Description, vbExclamation, "Error"
Resume Exit_LoadCustomIcon
End Sub
HTH