I've got an IIf statement that should do what I want, but its too complex so I need an alternative way of writing this code. I've tried a switch statement but have the same issue. The purpose of the code is difficult to explain, but I'll try to keep it simple, as I've found the context is important while searching for solutions.
Basically, I'm using a query to output a datasheet that can be used as a mock matrix. It needs to be able to be customized, i.e. 5x5, 7x7, 10x10, etc. and the values displayed need to change to reflect the dimensions. One of the tables the query pulls from is just number values that I use the sum of to determine the output of that field. There is also a field labeled "[Matrix Size]" that determines the dimensions. Eventually, this will also dictate what information gets displayed based on those dimensions, but I haven't gotten that far yet. The overly complex IIf statement(s) is as follows.
IIf([Matrix Size]<=0," ",
IIf([Impact]=0,"1",
IIf([Impact]+[Likelihood]=2,"Low",
IIf([Matrix Size]<2," ",
IIf([Impact]+[Likelihood]=3,"Low",
IIf([Matrix Size]<3," ",
IIf([Impact]+[Likelihood]=4,"Low",
IIf([Matrix Size]<4," ",
IIf([Impact]+[Likelihood]=5,"Low",
IIf([Matrix Size]<5," ",
IIf([Impact]+[Likelihood]=6,"Low",
IIf([Matrix Size]<6," ",
IIf([Impact]+[Likelihood]=7,"Low",
IIf([Matriz Size]<7," ",
IIf([Impact]+[Likelihood]=8,"Low","Error")))))))))))))))
If anyone knows of a way to simplify this/an alternate way of going about it that wont be too complex for access, please let me know. Any help is appreciated.
For Clarity, if needed:
The second IIf is used to set the first row to be "1", to act as one of the numerical values along a horizontal row. The impact+likelihood statements determine if the field should display a value of "Low","Medium", or "High", but for now "Low" is just a placeholder, and the matrix size statements determine if it should be blank or not based on desired dimensions.
0to"1",1to"2",2to"Low"and so on, which is easy because arrays are zero indexed. - tadman