I'm working on distributing a database using VS Tools for Office, and
am having trouble with linked images on forms/reports. The image
objects have a default path\file set on the .Picture property, which
becomes invalid when the user installs the database (ie: c:\devpath\
becomes c:\program files\mydbapp, but the .Picture property still
points to c:\devpath\) The problem is that I don't *know* what
installation path the user will select, so I can't hard-code a path
into the property. I technically can't even use "c:\dummy.jpg" because
I don't know the user has a drive c:\.
The forms/reports themselves work fine in print preview, as the
image.Picture property is set via VBA code to show the correct image
for that record. But when opening the database and opening the
forms/reports with linked image objects *in design view*, I get a
series of "can't open the file" errors. Errors when opening in design
view I can live with, since print preview works. But errors during
startup are not acceptable. I suspect it's the design-view errors
appearing during startup for some reason, so I think once one problem
is fixed, the other will be fixed as well.
I've read that some people recommend creating image objects with
Picture="(none)" or "", but Access 2003-SP2 won't let me do that. It
forces me to choose an image file, so I load in a dummy/default image
that ends up being replaced in VBA. (ie: c:\devpath\dummy.jpg)
I've tried updating the image.picture property for each object On-Open
so it points to a valid path, but that doesn't work; I still get "can't
open the file" errors. My guess is that design-view doesn't trigger
on-open.
I've tried updating the link to a valid devpath\filename then removing
the path from the .Picture property (since the helpfiles indicate the
Path is optional for the .Picture property). It seems to work, and it
appears as if only the filename is saved. I can then open/close/design
the report w/o any problems. But if I close the database, rename my
devpath directory, and open the database, it says it can't find the
images when I go back to that same report in design view. If I open the
report in design view and fix the first image so it references the new
path (leaving the others so they just reference the filename), then
*all* images on the report in design view show the default/dummy image
properly. Very odd. Is there a report property to define a "default
directory" for searching for images w/o paths?
I've also tried using system variables, code, and a custom function in
the .Picture box, with no success. ie: currentproject.path &
"\dummy.jpg" or %windir%\dummy.jpg or DefaultDir()
It seems like the .Picture property can only contain a uninterpreted
string.
Is there a way to set an image object so its .Picture property is
null/(None)/""?
Is there a way to type code into the .Picture property?
Is there some other solution to this quandary?