By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,471 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,471 IT Pros & Developers. It's quick & easy.

Pictures in a report? (A2K3)

P: n/a
PW
Hi,

I'd like to add a picture in a report where the path to the picture is
from a table, depending on the dogid that is on the report (in the
detail section).

How can I do this?

Thanks!

-paul
Oct 22 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
PW <pa**********************@removehotmail.comwrote :
>I'd like to add a picture in a report where the path to the picture is
from a table, depending on the dogid that is on the report (in the
detail section).
Incredibly easy. Using the Toolbox drop an image control on the reports detail
section. Note that you will have to follow the dialog and actually insert an image.
But then go to the Picture property on the Format tab in the property sheet and
delete the actual file. You will probably want to set the Size Mode from clip to
zoom. And rename the control.

Then in the report detail section in the On Print event you want to add the following
lines of code

If <logic if file available to viewThen
Me.PhotoImage.Picture = PhotoFilePath
Else
Me.PhotoImage.Picture = ""
End If

You don't want to do this logic in the Format event as Microsoft has told us, via
Stephen Lebans, that using that event can lead to memory leak problems. Or use BMP
images.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Oct 23 '08 #2

P: n/a
"Tony Toews [MVP]" <tt****@telusplanet.netwrote:

I forgot.

Loading Image dialogue

Getting tired of seeing that Loading Image dialogue flicker? Getting errors by users
who click on things before this is finished displaying? Try creating/changing the
following registry key as per the Access WEB at API: Suppress the "Loading Image"
dialog http://www.mvps.org/access/api/api0038.htm

As always make a backup of your registry and make changes to registry entries at your
own risk.

Joe Fallon, fellow MVP, states "I use the Tab control to "hide" the image on a
different "page". I also move the code to the OnGotFocus event of the ImagePath text
box which is on the next page of the Tab control. This way, the only time the picture
loads is when the user clicks the tab to see it".

Also for an extensive list of links see http://granite.ab.ca/access/imagehandling.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Oct 23 '08 #3

P: n/a
PW
On Thu, 23 Oct 2008 01:48:30 GMT, "Tony Toews [MVP]"
<tt****@telusplanet.netwrote:
>PW <pa**********************@removehotmail.comwrote :
>>I'd like to add a picture in a report where the path to the picture is
from a table, depending on the dogid that is on the report (in the
detail section).

Incredibly easy. Using the Toolbox drop an image control on the reports detail
section. Note that you will have to follow the dialog and actually insert an image.
But then go to the Picture property on the Format tab in the property sheet and
delete the actual file. You will probably want to set the Size Mode from clip to
zoom. And rename the control.

Then in the report detail section in the On Print event you want to add the following
lines of code

If <logic if file available to viewThen
Me.PhotoImage.Picture = PhotoFilePath
Else
Me.PhotoImage.Picture = ""
End If

You don't want to do this logic in the Format event as Microsoft has told us, via
Stephen Lebans, that using that event can lead to memory leak problems. Or use BMP
images.

Tony
Well, that is something I've never done before. Pretty cool, except I
can not figure out why the picture appears for all dogs/records! I go
into debug mode and varReturnVal is Null, but the picture still
appears. I stop it in debug, look at the value for the property on
the form and it is empty. I loaded up the first record with the
path to the jpg. I guess I have to study the IsNull function once
again!

Also, when I type in Me.imgDogPic Intellisense does not have a
picture property but somehow it saved fine:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim varReturnVal As Variant
Dim intDogID As Integer

intDogID = Me.txtDogID

varReturnVal = DLookup("[tDogPicLoc]", "dogs", "[iDog_ID]= " &
intDogID)

If IsNull(varReturnVal) Then
Me.imgDogPic.Picture = ""
Else
Me.imgDogPic.Picture = varReturnVal
End If

End Sub

Oct 23 '08 #4

P: n/a
PW
On Thu, 23 Oct 2008 01:48:30 GMT, "Tony Toews [MVP]"
<tt****@telusplanet.netwrote:
>PW <pa**********************@removehotmail.comwrote :
>>I'd like to add a picture in a report where the path to the picture is
from a table, depending on the dogid that is on the report (in the
detail section).

Incredibly easy. Using the Toolbox drop an image control on the reports detail
section. Note that you will have to follow the dialog and actually insert an image.
But then go to the Picture property on the Format tab in the property sheet and
delete the actual file. You will probably want to set the Size Mode from clip to
zoom. And rename the control.

Then in the report detail section in the On Print event you want to add the following
lines of code

If <logic if file available to viewThen
Me.PhotoImage.Picture = PhotoFilePath
Else
Me.PhotoImage.Picture = ""
End If

You don't want to do this logic in the Format event as Microsoft has told us, via
Stephen Lebans, that using that event can lead to memory leak problems. Or use BMP
images.

Tony

On Thu, 23 Oct 2008 01:48:30 GMT, "Tony Toews [MVP]"
<tt****@telusplanet.netwrote:
>PW <pa**********************@removehotmail.comwrote :
>>I'd like to add a picture in a report where the path to the picture is
from a table, depending on the dogid that is on the report (in the
detail section).

Incredibly easy. Using the Toolbox drop an image control on the reports detail
section. Note that you will have to follow the dialog and actually insert an image.
But then go to the Picture property on the Format tab in the property sheet and
delete the actual file. You will probably want to set the Size Mode from clip to
zoom. And rename the control.

Then in the report detail section in the On Print event you want to add the following
lines of code

If <logic if file available to viewThen
Me.PhotoImage.Picture = PhotoFilePath
Else
Me.PhotoImage.Picture = ""
End If

You don't want to do this logic in the Format event as Microsoft has told us, via
Stephen Lebans, that using that event can lead to memory leak problems. Or use BMP
images.

Tony
Well, that is something I've never done before. Pretty cool, except I
can not figure out why the picture appears for all dogs/records! I go
into debug mode and varReturnVal is Null, but the picture still
appears. I stop it in debug, look at the value for the property on
the form and it is empty. I loaded up the first record with the
path to the jpg. I guess I have to study the IsNull function once
again!

Also, when I type in Me.imgDogPic Intellisense does not have a
picture property but somehow it saved fine:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim varReturnVal As Variant
Dim intDogID As Integer

intDogID = Me.txtDogID

varReturnVal = DLookup("[tDogPicLoc]", "dogs", "[iDog_ID]= " &
intDogID)

If IsNull(varReturnVal) Then
Me.imgDogPic.Picture = ""
Else
Me.imgDogPic.Picture = varReturnVal
End If

End Sub
Oct 23 '08 #5

P: n/a
PW <pa**********************@removehotmail.comwrote :
>Well, that is something I've never done before. Pretty cool, except I
can not figure out why the picture appears for all dogs/records! I go
into debug mode and varReturnVal is Null, but the picture still
appears. I stop it in debug, look at the value for the property on
the form and it is empty. I loaded up the first record with the
path to the jpg. I guess I have to study the IsNull function once
again!
Did you go to the Picture property on the Format tab in the image controls property
sheet and clear the file name? Although I don't thnk that's your problem.
>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim varReturnVal As Variant
Dim intDogID As Integer

intDogID = Me.txtDogID

varReturnVal = DLookup("[tDogPicLoc]", "dogs", "[iDog_ID]= " &
intDogID)

If IsNull(varReturnVal) Then
Me.imgDogPic.Picture = ""
Else
Me.imgDogPic.Picture = varReturnVal
End If

End Sub
At first glance the above looks ok.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Oct 23 '08 #6

P: n/a
PW
On Thu, 23 Oct 2008 05:08:27 GMT, "Tony Toews [MVP]"
<tt****@telusplanet.netwrote:
>PW <pa**********************@removehotmail.comwrote :
>>Well, that is something I've never done before. Pretty cool, except I
can not figure out why the picture appears for all dogs/records! I go
into debug mode and varReturnVal is Null, but the picture still
appears. I stop it in debug, look at the value for the property on
the form and it is empty. I loaded up the first record with the
path to the jpg. I guess I have to study the IsNull function once
again!

Did you go to the Picture property on the Format tab in the image controls property
sheet and clear the file name? Although I don't thnk that's your problem.
>>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim varReturnVal As Variant
Dim intDogID As Integer

intDogID = Me.txtDogID

varReturnVal = DLookup("[tDogPicLoc]", "dogs", "[iDog_ID]= " &
intDogID)

If IsNull(varReturnVal) Then
Me.imgDogPic.Picture = ""
Else
Me.imgDogPic.Picture = varReturnVal
End If

End Sub

At first glance the above looks ok.

Tony

That's not it Tony, as far as I can tell. varReturnVal returns NULL
but yet the code runs.

Any ideas?

Thanks!

-paul
Oct 23 '08 #7

P: n/a

"PW" <pa**********************@removehotmail.comwrote in message
news:0h********************************@4ax.com...
On Thu, 23 Oct 2008 05:08:27 GMT, "Tony Toews [MVP]"
<tt****@telusplanet.netwrote:
PW <pa**********************@removehotmail.comwrote :
>Well, that is something I've never done before. Pretty cool, except I
can not figure out why the picture appears for all dogs/records! I go
into debug mode and varReturnVal is Null, but the picture still
appears. I stop it in debug, look at the value for the property on
the form and it is empty. I loaded up the first record with the
path to the jpg. I guess I have to study the IsNull function once
again!
Did you go to the Picture property on the Format tab in the image
controls property
sheet and clear the file name? Although I don't thnk that's your
problem.
>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim varReturnVal As Variant
Dim intDogID As Integer

intDogID = Me.txtDogID

varReturnVal = DLookup("[tDogPicLoc]", "dogs", "[iDog_ID]= " &
intDogID)

If IsNull(varReturnVal) Then
Me.imgDogPic.Picture = ""
Else
Me.imgDogPic.Picture = varReturnVal
End If

End Sub
At first glance the above looks ok.

Tony


That's not it Tony, as far as I can tell. varReturnVal returns NULL
but yet the code runs.

Any ideas?

Thanks!

-paul
Is the DLookup erroring out and not setting varReturnVal?
Oct 23 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.