-----Original Message-----
fredg said:
Lionel said:
I have a report that has as a control source a table
called "Inventory"
I also have a table called "FilePath" that contains only
one record, which is changed from time to time.
When printing a report, the event "On Format" in the
Detail section of the report populates the Picture
control of an image with a pathway to the image file.
How do I specify the field "FilePath" in the
table "FilePath" in the "On Format" event procedure?
Lionel
Lionel,
Dim strThePath as String
strThePath = DLookUp("[PathField],"tblFilePath")
ImageName.Picture = strThePath & [ImageNameField]
If strThePath is "c:\FolderName\"
and
[ImageNameField] is "FordMustang.jpg"
then the ImageName.Picture will be
"c:\FolderName\FordMustang.jpg"
If the Path is the same for all the images in the report,
Dim the variable up in the Declarations section of the code window, and
place the DLookUp() in the Report Format event, so that it won't have to
repeat the same DLookUp for each picture, otherwise place all the code
in the Detail Format event.
OOps... a slight correction.
I left out a quote. The DLookUp should be:
strThePath = DLookUp("[PathField]","tblFilePath")
and I just noticed that you posted that the table AND the field name are
both the same "FilePath".
That's a sure way to create a problem.
Notice in my sample above, I automatically gave the field a name
different than the table name.
Change the Table name to 'tblFilePath'.
And/Or change the Field name to 'txtFilePath'.
Give Access a fighting chance, as well as the next person who has to
work on your database, or even yourself in 6 months or so. What may be
perfectly clear to you today will be long forgotten by then.
'tblFilePath' and 'txtFilePath' will differentiate between which refers
to the table and which refers to the field.
--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.