William Benson (VBACreations.Com)
vbacreations at gmail.com
Thu May 30 20:58:19 CDT 2013
I am wanting to have the same Header fields and image appear on every form in my database. The query which populates these items has SQL: SQL = "" SQL = SQL & " SELECT " SQL = SQL & " First([Build Date]) AS AppBuildDate," SQL = SQL & " First(ApplicationImage.FileData) As AppImage" SQL = SQL & " FROM 9997_DevelopmentVersion as Tbl" SQL = SQL & " WHERE " SQL = SQL & " [Build Date]=(Select Max([Build Date]) from 9997_DevelopmentVersion);" I have also tried substituting ApplicationImage for ApplicationImage.FileData So far I have been unable to set an image control's defaultpicture property to a RECORDSET FIELD from a recordset created with that SQL statement. Can someone help with the syntax to set the DefaultPicture of an unbound image control to an attachment identified by a field in a recordset described above? I have been having to resort to saving the attachment to disk, and assigning it to the defaultpicture property, then killing the file: Const SOME_PATH = "c:\username\temp\x.ico" Set d = CurrentDb SQL = "" SQL = SQL & " SELECT " SQL = SQL & " First([Build Date]) AS AppBuildDate," SQL = SQL & " First(ApplicationImage) As AppImage" SQL = SQL & " FROM 9997_DevelopmentVersion as Tbl" SQL = SQL & " WHERE " SQL = SQL & " [Build Date]=(Select Max([Build Date]) from 9997_DevelopmentVersion);" Set r = d.OpenRecordset(SQL) Set rsPic = r.Fields("AppImage").Value If Not rsPic.EOF Then On Error Resume Next Kill SOME_PATH On Error GoTo 0 rsPic.Fields("FileData").SaveToFile SOME_PATH End If imgApplicationIcon.DefaultPicture = SOME_PATH On Error Resume Next Kill SOME_PATH On Error GoTo 0