Question : Reusing an iif statement in MS Access

I have an IIF statement that I'm using in an Access Query that calculates what grade a student should be in based on age.  It's working fine.

However, I need to reuse that IIF in multiple queries and it is quite complex to update every year so I would like to put it in one place.

Is there a way I can put this complex IIF in a module or something then call it from the queries?

MS Access 2000

Answer : Reusing an iif statement in MS Access

<>

 yes.  You can move the logic into a Function in a general module and then call the function from the queries.  The only trick is is that you must pass in a field name to the function so it gets called for each row.  Doesn't matter what field it is or even if the function uses it, just that you pass one (it's because of the optimizer that runs queries).

Post your IIF and I'll show you how to put it in a function.

JimD.

Random Solutions  
 
programming4us programming4us