Or - if you prefer to keep using the IIF expression, you could do this:
iif([condition1],[returnvalue1],iif([condition2],[returnvalue2],iif([condition3],[returnvalue3],[returnvalue4])))
Basically, if you want to nest iif statements, just keep on adding new iif statements to the "else" part of the statement. The main thing you have to make sure you do, however, is to have an "else" statement right at the end ([returnvalue4] in the above example), and have the right amount of closing parentheses, which is easy to do: just count the number of times "iif" shows up in your expression, and put that many closing parentheses at the end (in my example, "iif" is in there 3 times, so there's 3 closing parentheses)
But, especially given that you're using this in a form, I would do as Mike says, and use a Select Case statement. You should only nest "iif" statements if you cant use Select Case statements.
But as a fallback, you should also always have a "Case Else" part in your statement, in case something odd happens, such as:
Code:
SELECT CASE me.txtFirstTextBox
Case 1 to 30
Me.txtSecondTextBox = 1
Case 21 to 60
Me.txtSecondTextBox = 2
'And so on
Case Else
Me.txtSecondTextBox = -1
MsgBox "Oh no! something bad happened! Oh what a world"
End Select
HTH
Steven
I am a loud man with a very large hat. This means I am in charge
(Edited due to typo)