How to change a report logo based on criteria

Accessible92866

Registered User.
Local time
Yesterday, 23:49
Joined
Nov 4, 2008
Messages
11
Turning to the expert minds for help...

Upfront note: I have been writing databases for years but haven't really gone beyond basic macros for automation. I'm not a programmer and have very little experience with VBA, so if you explain things as if you were talking to a small child, I won't be offended. :)

I have a report (Access 2007) based on a parameter query and in the report header, I'd like the image control named "logo" to change based on which client is requested in the query.

  • Should I use Select...Case to change the pathname to the image according to which [ClientName] is chosen? (There are only five possible clients and I don't think the number will increase anytime soon.)
  • Would it be better to stack the five images on top of each other and turn their visible/invisible properties on or off?
  • Where should the code be placed? Somewhere in the report properties or the image control properties?
As you can see, I know what I want to do, but don't have much of a clue how to go about it and am pretty lost.

Thanks in advance for any assistance you can offer!
 
I wouldnt use the image control, as it leads to bloat. You should link the control to the destination of the image. You could use select case, but since your new to vba, maybe if statements will be easier. I believe the event this goes in is called On_Format.

I posted a similar question that you can seehere.

Code:
if CRITERIA 1 then
me.[nameofcontrolhere].picture="yourimagepathhere"
else
if CRITERIA 2 then
me.[nameofcontrolhere].picture="yourimagepathhere"
end if
end if
 
As an experiment, I tried Select Case and obviously did something wrong since it didn't work...and then I followed your suggestion about keeping it simple, used IF and hurray--success!

Someday I want to get Select Case to operate correctly and I was intrigued by the DLookup answer you received on your post, but for now, all is well and the report is good to go. :D

With much appreciation,
Accessible92866
 
Glad to have helped.

The dlookup was used because I believe my problem was different. First, I had a table solely for paths to images files. I was trying to point 6 different controls to particular records in that table. Thats why I used dlookup.

Also, the Select Case may be an option for you. If you have many different criteria, it may also be a better option, because vba will run through all the if statements. So if you have a lot of if statements, then it could be a little slower than you would like. For this question, I would imagine you only have a few different pictures, so it probably doesnt matter.
 
The better idea is to reference the images, so I the Client point to the image file name i.e.

Client_Logo_Type = 1
Client_Logo_Type = 2

In your Query the ImageFile:

[Image Path] & [Client_Logo_Type] & ".jpg"

This is a simplistic representation but is Client sensitive.

Simon
 

Users who are viewing this thread

Back
Top Bottom