If statement for image

Turbo910

Registered User.
Local time
Today, 09:32
Joined
Nov 8, 2009
Messages
43
hey

On one of my forms (Products In) has a text box on it the shows what unit a product is in, either 9 or 10, and basically when the unit shows 9 i want an image to show of unit 9 layout, if its 10 then i want an image to show a picture of the layout of unit 10.

Can anyone assist me in doing this please :)

Im using access 2007

Thanks
 
Put an image control on the form
imgbtn01.png


and then set the control source to:

=IIf([FieldNameHere]=9,"\\ServerName\ShareName\PathToFile\imagename9.jpg","\\ServerName\ShareName\PathToFile\imagename10.jpg")

Where ServerName\ShareName\PathToFile is the file path to the pic

and imagename9.jpg and imagename10.jpg are the respective names of the pic files.
 
Ok so thats great it works thankyou,
One problem though i want no image to be showing if the value of the unit text box is null. The unit 10 image is always showing if the value is null or 10 has been selected??
 
Change the IIf to a nested IIf:

=IIf(IsNull([FieldNameHere],"",IIf([FieldNameHere]=9,"\\ServerName\ShareName\PathToFile\imagename9.j pg","\\ServerName\ShareName\PathToFile\imagename10 .jpg"))
 
Is thats correct becuase its saying it has the wrong amount of arguements for the function? :s
 
=IIf(IsNull([Unit],"",IIf( [Unit] =9,"C:\Users\Tom Burman\Documents\First Light\Floor plan unit 9.png","C:\Users\Tom Burman\Documents\First Light\Floor plan unit 10.png"))
 
=IIf(IsNull([Unit],"",IIf( [Unit] =9,"C:\Users\Tom Burman\Documents\First Light\Floor plan unit 9.png","C:\Users\Tom Burman\Documents\First Light\Floor plan unit 10.png"))
Ah, yes, I forgot an ending paren after the IsNull function:

=IIf(IsNull([Unit]),"",IIf( [Unit] =9,"C:\Users\Tom Burman\Documents\First Light\Floor plan unit 9.png","C:\Users\Tom Burman\Documents\First Light\Floor plan unit 10.png"))
 
and now the unit 9 image is showing when the value is null
 
I think it has to do with the "" not changing the pic from the last picture. If you create a blank picture (just a white square) and then set IT to load if IsNull([Unit]) instead of "" then that should work.
 
Hi,
I also had a similar problem, and came across this forum.

My issue is similar but my formula does not work, I have noticed it does not work if your text box equals a text response. I may have missed a step but this is my formula:

=IIf(IsNull([text97]),"",IIf( [text97] =THE ZOMBIES ARE COMING!!!," C:\Documents and Settings\Jason\My Documents\My Pictures\Zombie Lurch Left.png","C:\Documents and Settings\Jason\My Documents\My Pictures\Zombie Lurch Right.png"))
 
Firstly welcome to the forum.
I think the problem is that Your text string should be enclosed in Double quotes;
Code:
=IIf(IsNull([text97]),"",IIf( [text97] =[B][COLOR="Red"]"[/COLOR][/B]THE ZOMBIES ARE COMING!!![COLOR="Red"][B]"[/B][/COLOR],"C:\Documents and Settings\Jason\My Documents\My Pictures\Zombie Lurch Left.png","C:\Documents and Settings\Jason\My Documents\My Pictures\Zombie Lurch Right.png"))
 
Last edited:

Users who are viewing this thread

Back
Top Bottom