Controls on a report

  • Thread starter Thread starter Lionel Fridjhon
  • Start date Start date
L

Lionel Fridjhon

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 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.
 
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
Thanks for the help - works fine!!
(I caught the error in your reply.)

Next problem - I have a procedure which gives a user a
standard Windows dialog box to select a new file path to
the images.

This data is stored in a variable called "DataFilePath".

How can I replace the entry in the 1 record, 1 field
table called "tblFilePath" with this new string?

Lionel
..

-----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.
.
 
Back
Top