img on reports

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have clients that want to have their logo on each report
and or change the logo with out a Run time error 94 (empty
string)
I have placed a text box in a form where they type in the
path to their image on the hard drive, then i place an
empty picturebox on each report with the below code!(which
works well)
I have tried if IsNull etc and nothing works to stop the
error messge when the string is empty, any thoughts please?
my code to place the image:\
Dim strPath As String

strPath = DLookup("[logotest]", "My Company
Information")
Me!imgPicture.Picture = strPath
 
I can't reproduce the error message you describe. If I set an Image
Control's Picture property to an empty string, I get no message at all. If I
set it to a Null, I get a "Runtime error 13 Type mismatch".

I suggest that you surround the code that actually sets the Picture property
as follows:

If Len(strPath) <> 0 Then
Me!imgPicture.Picture = strPath
End If

And, if you really meant that the user has to _type_ in the path and file of
the logo, I suggest you use the code donated by Ken Getz, which you'll find
in http://www.mvps.org/access/api/api0001.htm to open the Windows Common
Dialog so the user can _choose_ a file (and thus not risk making one typo in
a long text string that will cause the operation to fail and increase the
user's frustration level). If you need more example than comes in that
article, you'll find it used in the Imaging example databases at
http://accdevel.tripod.com.

Larry Linson
Microsoft Access MVP
 
Hi Larry
i do not want to sound stupid butttt!
I open the back of my report -then open the toolbox, i
only have an imagecontrol, i place this and then remove
the imgpath, then place the code in the form pointing to
the img, then i write the string in the "Company
Information form" it does not have a property to set
(empty string)
i have tried your first suggestion, this removes the img
despite the path in the text box in the enter the path
form has not been removed.
Any more ideas???
Or have done it the wrong way from the begining?
by the way i can not find a picturebox, only in VB
DD
-----Original Message-----
I can't reproduce the error message you describe. If I set an Image
Control's Picture property to an empty string, I get no message at all. If I
set it to a Null, I get a "Runtime error 13 Type mismatch".

I suggest that you surround the code that actually sets the Picture property
as follows:

If Len(strPath) <> 0 Then
Me!imgPicture.Picture = strPath
End If

And, if you really meant that the user has to _type_ in the path and file of
the logo, I suggest you use the code donated by Ken Getz, which you'll find
in http://www.mvps.org/access/api/api0001.htm to open the Windows Common
Dialog so the user can _choose_ a file (and thus not risk making one typo in
a long text string that will cause the operation to fail and increase the
user's frustration level). If you need more example than comes in that
article, you'll find it used in the Imaging example databases at
http://accdevel.tripod.com.

Larry Linson
Microsoft Access MVP


David said:
I have clients that want to have their logo on each report
and or change the logo with out a Run time error 94 (empty
string)
I have placed a text box in a form where they type in the
path to their image on the hard drive, then i place an
empty picturebox on each report with the below code! (which
works well)
I have tried if IsNull etc and nothing works to stop the
error messge when the string is empty, any thoughts please?
my code to place the image:\
Dim strPath As String

strPath = DLookup("[logotest]", "My Company
Information")
Me!imgPicture.Picture = strPath


.
 
Back
Top