Using IIf in Data Section within Group
How do I write a workable IIf(,,,) expression to test the boolean column's value of the current data record within a group band's data section? I have tried endless variations, many of which generate an error about how the name of the record is not within the current context. In a text box I can easily show the value itself, but I cannot find a way to test that same value with IIf(,,,). Here is an example of what fails:
[IIf(ContactFamiles.Baptized,[Baptized],[Unbaptized])] even though this works fine: [ContactFamilies.Baptized]
This discussion has been closed.
Comments
Finally got it. Although I could see no visible difference, the column needed to be dragged into the IIf template using the expression editor, rather than just trying to type the same text in. Odd. This did work, even though I'm pretty sure I had earlier typed the exact same thing without using the expression editor:
[IIf([ContactFamilies.Baptized] == true,[Baptized],[Unbaptized])]
Hello!
As the column is already of type `bool`, both notations are valid:
[IIf([ContactFamilies.Baptized], ‘Baptised’, ‘Unbaptised’)]// or explicitly:
[IIf([ContactFamilies.Baptized] == true, ‘Baptised’, ‘Unbaptised’)]Without square brackets, the C# compiler interprets ContactFamilies.Baptized as a local identifier within the script code and fails with a compilation error.