>>Can I do an IIF statement in a textbox.controlsource? Further, can that IIF statement call a UDF which passes a value back to the control source for display on the screen?
>>
>>Thanks, Randy
>
>From the property sheet, no (Data Source for this object must be a variable reference). From the Init method I was able to do:
>
>this.ControlSource = IIF(condition,'FirstVar','SecondVar')
>
>and it was accepted and updated the proper variable.
Note that we're talking about two things here: one is an iif() used to determine what would be the controlsource (that's what you suggest), and the other is something like
.controlsource='(iif(condition,alias1.field1,alias2.field2))'
which would be recalculated on each refresh. Note the parentheses around the whole expression, which tell the PEM parser (or whatever the engine may be called) to re-evaluate the expression, instead of evaluating it only once, or binding it permanently.
Though, I think a field like the one above may be read-only or at least unbound. I know this is a regular way to include a calculated field into a grid - use something like this in column's controlsource, but I'm not really too sure whether it is bound or not.