IF Statement Code

L

Liz Steffen

I have been unsuccessfully trying to create the following code from Excel
into VB for an Access report. Can someone please help?
Thank you,
Liz
 
T

Tom Lake

Liz Steffen said:
I have been unsuccessfully trying to create the following code from Excel
into VB for an Access report. Can someone please help?
Thank you,
Liz

Try this:

IIf(_sold-volume>0,IIf(_onhand-volume<_sold-volume,_onhand-volume,_sold-volume),0)Tom Lake
 
L

Liz Steffen

I put your code directly into the field on my Access report and it prompts me
to input the Sales Volume and OnHand Volume values, but those are coming from
the query. Can you offer me more help?
 
T

Tom Lake

Liz Steffen said:
I put your code directly into the field on my Access report and it prompts
me
to input the Sales Volume and OnHand Volume values, but those are coming
from
the query. Can you offer me more help?

The report's data source IS the query, right?

Don't forget the =

=
IIf(_sold-volume>0,IIf(_onhand-volume<_sold-volume,_onhand-volume,_sold-volume),0)


Tom Lake
 
L

Liz Steffen

Yes, I figured this one out, I appreciate your help on it, I couldn't have
done it without your code. However, now, when I put in a Total field for
that field that has the IIF statment, it is prompting me for a parameter and
when I don't put one in, it doesn't do the sum. Can you not sum a field that
does a calculation?
 
O

OfficeDev18 via AccessMonster.com

Yeah, but this one's complex. You need to put the whole formula into the
source data for the control, like this: =Sum(IIf(_sold-volume>0,IIf(_onhand-
volume<_sold-volume,_onhand-volume,_sold-volume),0))

HTH

Liz said:
Yes, I figured this one out, I appreciate your help on it, I couldn't have
done it without your code. However, now, when I put in a Total field for
that field that has the IIF statment, it is prompting me for a parameter and
when I don't put one in, it doesn't do the sum. Can you not sum a field that
does a calculation?[quoted text clipped - 10 lines]
 
Top