Hi Richard. I'm trying to create an IIF function where, if the data in my column headed IncomeExpense is Expense, the amount in my Amount column is changed to a negative figure. Following your Expert Level 8 lesson 4, I have typed in: IIF([IncomeExpense]=[Expense],[Amount]*-1). When I run it, a popup box asks for the parameter value of IncomeExpense. Where am I going wrong please?
Reply from Richard Rost:
Well, is IncomeExpense a TEXT field that says "Expense"? If so, you'd need:
IIF(IncomeExpense="Expense",Amount*-1,Amount)
If you put something like that in [brackets] then you're telling Access it's a FIELD NAME. You don't need the brackets if your field names don't have spaces in them (which is what I teach in the very first Beginner lessons). However, if you want the VALUE of the data in that field, you CAN'T use brackets.
I'd recommend a Yes/No field. Make YES an income and NO an expense. Then you could just say:
IIF(IncomeExpense,Amount,Amount*-1)
The field will evaluate to TRUE or FALSE based on it's value and you'll get either the Amount or it's negative.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 8.