Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested iif versus VBA Code

Status
Not open for further replies.

citychap26

Programmer
Sep 19, 2004
144
GB
Hi Chaps,

I would rather go for VBA Code as you have more control. However what do you guys think.

Sorry this is a bit wooly.

Cheers

SK
 
Maybe an example would help untangle the wool? :)
 
Hi Remou,

I am talking in general. Sorry do not have an example to hand.

Cheers

SK
 
CityChap26,
Think of those who will come after you and have to support what you have written. (Of course your code will remain in use for years and need occasional updating). I find VBA somewhat easier to read and more easily modified, especially if future requirements increase the number or complexity of options.
Hope that helps.
HCEONETMAN
 
I would do a 2 level nested iif, but any more I'd go for code.

That is assuming everything else to be equal...

--------------------
Procrastinate Now!
 
If you can get a hand on the Access Desktop Developers Handbook (pages 1006 and 1007 of 2k), you would see that you want to always avoid using the iif when writing VBA code. In a query or form or report the problems are not as bad. However, the iif has a lot of issues and a lot of overhead. Run a time test on your nested iif and VBA your code, and most likely you will see significant improvement in your code. My personal preference is to avoid any nested iif's. One thing to keep in mind, is shorter code does not mean better performance.
 
What is "talking in general"?

Being a bit less "wooly" makes it a bit easier to address the issue at hand.

If this relates to usage within queries vs calling VBA, I don't know for sure, I very seldom use iif's, so I have very little experience, it's probably related to the complexity, but in a lot of cases, you'll be able to avoid nested iif's by using for instance the Choose() function or the Switch() function within the query (look them up in the help file and/or search for samples here, perhaps in the query forum (forum701)). Would be interesting with a comparision of those vs nested iif's vs VBA ...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top