Procedure for On Print Event

  • Thread starter Lionel Fridjhonj
  • Start date
L

Lionel Fridjhonj

I have an image in my report acting as a placeholder for
the pictures attached to each record.\
Each record in the table has a field with the filepath to
the appropriate picture.

How do I write the "On Print" event procedure to replace
the current filepath in the "Picture" property of the
placeholder with the appropriate file path for the record
being printed?

I am using this method because inserting the pictures
into the field of the table produces a mammoth database
file of about 3 - 4 Gb.

Lionel
 
F

fredg

Lionel said:
I have an image in my report acting as a placeholder for
the pictures attached to each record.\
Each record in the table has a field with the filepath to
the appropriate picture.

How do I write the "On Print" event procedure to replace
the current filepath in the "Picture" property of the
placeholder with the appropriate file path for the record
being printed?

I am using this method because inserting the pictures
into the field of the table produces a mammoth database
file of about 3 - 4 Gb.

Lionel

Lionel,
I would suggest the Format event, not the Print event.

Something like one of these expressions, depending upon the actual data
in the field. If the path and folder is the same for each image, there
is no need to include it with the ImageNameField.

[ImageName].Picture = "c:\FolderName\" & [ImageNameField]
or..
[ImageName].Picture = "c:\" & [PathNameField] & "\" & [ImageNameField]
 
L

Lionel Fridjhon

Fred
Thanks for the reply.
I built the following expression in the "On Format" Event:

=[IconPlaceHolder].Picture=[Inventory]![FilePath] &
[Inventory]![FileName]

The "=" in the expression is put there by the system.
Is this correct, or do I need to put the expression in
parentheses?
(The field [FilePath] contains the backslash).

I get an error message that the object doesn't contain
the automation object "Inventory".

What am I doing wrong?

Lionel

-----Original Message-----
Lionel said:
I have an image in my report acting as a placeholder for
the pictures attached to each record.\
Each record in the table has a field with the filepath to
the appropriate picture.

How do I write the "On Print" event procedure to replace
the current filepath in the "Picture" property of the
placeholder with the appropriate file path for the record
being printed?

I am using this method because inserting the pictures
into the field of the table produces a mammoth database
file of about 3 - 4 Gb.

Lionel

Lionel,
I would suggest the Format event, not the Print event.

Something like one of these expressions, depending upon the actual data
in the field. If the path and folder is the same for each image, there
is no need to include it with the ImageNameField.

[ImageName].Picture = "c:\FolderName\" & [ImageNameField]
or..
[ImageName].Picture = "c:\" & [PathNameField] & "\" & [ImageNameField]

--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
 
F

fredg

Lionel said:
Fred
Thanks for the reply.
I built the following expression in the "On Format" Event:

=[IconPlaceHolder].Picture=[Inventory]![FilePath] &
[Inventory]![FileName]

The "=" in the expression is put there by the system.
Is this correct, or do I need to put the expression in
parentheses?
(The field [FilePath] contains the backslash).

I get an error message that the object doesn't contain
the automation object "Inventory".

What am I doing wrong?

Lionel

No, it is not correct.
IF.... the name of the Image Control is [IconPlaceHolder], and
[FilePath] and [FileName] are fields in the [Inventory] table, and are
included in the Report's RecordSource, then the code in the Detail
Format event should be:

[IconPlaceHolder].Picture = [FilePath] & [FileName]

Assuming [FilePath] contains data like:
c:\MyPictureFolder\
and [FileName] contains something like:
AngelFoodCake.jpg

Then the Image.Picture will be
c:\MyPictureFolder\AngelFoodCake.jpg

I hope this helps.
 
L

Lionel Fridjhon

Fred
Thanks again - this time I get no error messages after
following your advice BUT when I ask for a preview of the
report, the screen flickers as though it has just gone
through all the records, but does not produce a report.

The expression in the On Format Event of the Detail
section is:

=[IconPlaceHolder].Picture=[FilePath] & [FileName]

Any ideas?

Lionel
-----Original Message-----
Lionel said:
Fred
Thanks for the reply.
I built the following expression in the "On Format" Event:

=[IconPlaceHolder].Picture=[Inventory]![FilePath] &
[Inventory]![FileName]

The "=" in the expression is put there by the system.
Is this correct, or do I need to put the expression in
parentheses?
(The field [FilePath] contains the backslash).

I get an error message that the object doesn't contain
the automation object "Inventory".

What am I doing wrong?

Lionel

No, it is not correct.
IF.... the name of the Image Control is [IconPlaceHolder], and
[FilePath] and [FileName] are fields in the [Inventory] table, and are
included in the Report's RecordSource, then the code in the Detail
Format event should be:

[IconPlaceHolder].Picture = [FilePath] & [FileName]

Assuming [FilePath] contains data like:
c:\MyPictureFolder\
and [FileName] contains something like:
AngelFoodCake.jpg

Then the Image.Picture will be
c:\MyPictureFolder\AngelFoodCake.jpg

I hope this helps.

--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
 
F

fredg

Lionel said:
Fred
Thanks again - this time I get no error messages after
following your advice BUT when I ask for a preview of the
report, the screen flickers as though it has just gone
through all the records, but does not produce a report.

The expression in the On Format Event of the Detail
section is:

=[IconPlaceHolder].Picture=[FilePath] & [FileName]

Any ideas?

Lionel
-----Original Message-----
Lionel said:
Fred
Thanks for the reply.
I built the following expression in the "On Format" Event:

=[IconPlaceHolder].Picture=[Inventory]![FilePath] &
[Inventory]![FileName]

The "=" in the expression is put there by the system.
Is this correct, or do I need to put the expression in
parentheses?
(The field [FilePath] contains the backslash).

I get an error message that the object doesn't contain
the automation object "Inventory".

What am I doing wrong?

Lionel

No, it is not correct.
IF.... the name of the Image Control is [IconPlaceHolder], and
[FilePath] and [FileName] are fields in the [Inventory] table, and are
included in the Report's RecordSource, then the code in the Detail
Format event should be:

[IconPlaceHolder].Picture = [FilePath] & [FileName]

Assuming [FilePath] contains data like:
c:\MyPictureFolder\
and [FileName] contains something like:
AngelFoodCake.jpg

Then the Image.Picture will be
c:\MyPictureFolder\AngelFoodCake.jpg

I hope this helps.

--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.

Lionel,
Are you placing that directly on the Detail Format event line?
That's not where it goes.

Let's go backwards a moment.
To write an event code, open the Report's property sheet.
Click anywhere on an empty part of the Detail section.
Click on the Events tab.
On the line that says On Format write
[Event Procedure]
Then click on the button with the 3 dots that will appear on that line.
The detail Format event Code window will open with 2 already existing
lines.
Write
[IconPlaceHolder].Picture = [FilePath] & [FileName]
between those 2 lines.
Note... there is NO = sign at the beginning of this line
When done the 3 lines should look like this:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

[IconPlaceHolder].Picture = [FilePath] & [FileName]

End Sub

Exit the code window. Run the Report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top