Default images in a report (1 Viewer)

RLauterbach

New member
Local time
Yesterday, 23:32
Joined
Oct 13, 2011
Messages
4
I have a report in which I wish to display different logos depending on the customer chosen, pulled from an image field in the customer table. Only a few customers have a bitmap entered in the customer table. I would like to have a default bitmap (our logo) for any customer with nothing in the image field. Putting the default bitmap into the table for every customer without a logo would make the database huge. I tried setting up an IIf situation in the report. When a bitmap exists, it prints. When none exists, the default doesn't print.

Can anyone offer suggestions?
 

vbaInet

AWF VIP
Local time
Today, 05:32
Joined
Jan 22, 2010
Messages
26,374
What you should be doing is storing the images on your hard drive and using the full path to display the image related to a customer. Have a look at this:

http://support.microsoft.com/kb/285820

Then for a default image, you would simply do:

Code:
=Nz([PathField], "C:\[COLOR=Red]Path to default image[/COLOR]")
This means, if [PathField] is Null (or empty) use the path to the default image instead. Ensure that in the PathField, the Allow Zero-Length property is set to No.
 

boblarson

Smeghead
Local time
Yesterday, 21:32
Joined
Jan 12, 2001
Messages
32,059
Which version of Access are you using?
 

speakers_86

Registered User.
Local time
Today, 00:32
Joined
May 17, 2007
Messages
1,919
Code:
=Nz([PathField], "C:\[COLOR=Red]Path to default image[/COLOR]")
Expanding on this a little...with this your default image must have the same root as your database.

Code:
dim Path as string
dim File as string
dim FullPath as string
Path = currentproject.path
File = "\default image location.jpg"
FullPath= Path & File
me.yourimagefield.defaultimage=Nz([PathField], FullPath)

".defaultimage" may be a off a little. Intellisense will probably tell you what it really is.
 

vbaInet

AWF VIP
Local time
Today, 05:32
Joined
Jan 22, 2010
Messages
26,374
It's not a must but it makes perfect sense to do so. Also I don't think an Image Control has a DefaultImage property.

If you do put the image in the same directory as your database, you can still do it in the Control Source in one line:
Code:
=Nz([PathField], CurrentProject.Path & "\Image Name.bmp")
 

RLauterbach

New member
Local time
Yesterday, 23:32
Joined
Oct 13, 2011
Messages
4
Thanks all.

I neglected to mention that I am using Access 2003 at the moment.

Things I read made a big point of portability, i.e. moving the database to a different location and losing the connection to the images. It was mentioned in these posts also, but you've offered recommendations to avoid the issue, so I'll try them.
 

Max D

Registered User.
Local time
Yesterday, 21:32
Joined
Jul 3, 2009
Messages
91
Does default picture is visible in report preview?
 

RLauterbach

New member
Local time
Yesterday, 23:32
Joined
Oct 13, 2011
Messages
4
No, if I choose a customer with no bmp in its record, nothing shows in preview. If I choose a customer that does have a bmp, the image shows in preview and in print.
 

RLauterbach

New member
Local time
Yesterday, 23:32
Joined
Oct 13, 2011
Messages
4
I didn't want to allow the late comment to go unanswered. I have not had time to implement the recommendations, so I can't say for certain it is resolved.
 

Users who are viewing this thread

Top Bottom