conditional text content

PortalMelt

New member
Local time
Today, 16:00
Joined
Oct 8, 2002
Messages
7
I can't find how to do this.

(Note: I'm sure this syntax is all wrong, I don't know Access very much)
In my report I need to do something like :

IF (Before OH > 0) AND (([Before OH]+[OH Cost Calc])<0) DISPLAY "OH", ELSE DISPLAY " "

and then this one:

IF (Before OH < 0) AND (([Before OH]+[OH Cost Calc])<0) DISPLAY "COST", ELSE DISPLAY " "

How do I do this?

Thanks,
Jeff
 
Try searching the help files for the use of IIf, your code might look something like the following:

IFF ("[Before OH] < 0 AND [Before OH]+[OH Cost Calc]<0","COST", " ")

Hope this points you in the right direction.

Paul
 
Stew,

That worked (after I changed IFF to IIF). I now need to combine the two examples I gave, so it will be like:

if
test A = true, display "OH",
elseif
test B = true, display "COST",
else
display " "

I will work on it, but if you know how right away, I will appreciate a pointer also.

Thanks,
Jeff
 
Oops, darn typos.

If you want to evaluate a couple of conditions then you probably should use code in the module of the report (you could use a nested IIf statement but it gets tricky). Try something like this on the open event of the report:

If [Before OH] < 0 then

Me.txt_title = "Oh"

Elseif [Before OH] > 0 then

Me.txt_title = "Cost"

else

me.txt_title = "Equal"

End If

Have Fun.

Paul
 
I went with the nested IIF and this code is working for me. Thanks for the discussion as it helped move me forward to the solution.

=IIf([Before OH]>0 And [PROFIT]<0,"OH",IIf([Before OH]<0 And [PROFIT]<0,"COST",""))

Jeff
 
I'm happy to be of some help, I hope the rest of your project goes well.

Gotta love the nested IIf statements.

Paul
 

Users who are viewing this thread

Back
Top Bottom