[AccessD] set the DefaultPicture of an unbound image control to an attachment in a recordset field?

William Benson vbacreations at gmail.com
Fri May 31 12:34:04 CDT 2013


I am just trying to work with images and learn how to read an image from an
attachment.

Thanks
On May 31, 2013 1:14 PM, "Charlotte Foust" <charlotte.foust at gmail.com>
wrote:

> I'm a little confused as to why you would have to "look up" an image if
> you're going to use it on every form.  Why not just build a subform with
> that image embedded and put it on every form?  Sometimes using code is the
> hard way.  I could see using the code to change the text perhaps, but not
> the image.  Way too much effort.
>
> Charlotte
>
> On Thu, May 30, 2013 at 6:58 PM, William Benson (VBACreations.Com) <
> vbacreations at gmail.com> wrote:
>
> > 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
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list