Report Graphics problem

P

Paul3rd

Hello,
I have placed graphics on my Access 2003 forms with no problem but I cannot
get the following code to work correctly on a unbound Access report.

Private Sub FormHeader_Format(Cancel As Integer, FormatCount As Integer)
Dim strPath As String
strPath = "Me.txtImgLogo"

Me.ImgLogo.Picture = strPath
Me.ImgLogo.Visible = True

End Sub
(Intellisense did not provide the .Picture property, I typed it in)
I receive a Runtime Error '2220'
Can't open file 'Me.txtImgLogo'.
Where:
ImgLogo is an embedded picture in the header.
txtImgLogo is a text box containing a file path to the image.
Can anyone help?
Thanks in advance
Paul
 
K

Ken Sheridan

You are setting the path to the literal string "Me.txtImgLogo". It should be
a reference to the control:

strPath = Me.txtImgLogo

The text box will already need to contain the path to the image file of
course when the relevant section of the report is formatted. This could be
by reference to a control on an external form, or you could pas the value to
the report as its OpenArgs property if the report is opened in code by
calling the OpenReport method. You could of course enter the path as the
ControlSource property of txtImgLogo, but that would make little sense as you
could simply set the Picture property of the image control to the path and do
without the text box.

ImgLogo should be an Image Control, not an Object Frame. The Picture
property does not show up in the list of properties via Intellisense. The
line of code is actually an abbreviated form of:

Me.ImgLogo.Properties("Picture") = strPath

You'll see that Properties (the control's Properties collection) does show
up in the list.

Ken Sheridan
Stafford, England
 
P

Paul3rd

Thanks Ken,
That worked fine.
I appreciate the help and explanation of what I did wrong.
Have a good day!
Paul
 

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