I have a query selecting many fields, and based on a boolean value I want it to be sorted along one of two fields:
...
ORDER BY IIF(GetBooleanValue(),[MyTable].[MyField1],[MyTable].[MyField2]);
GetBooleanValue is a function in Globals module, MyField1 is a long integer field, MyField2 is a short text field.
It works just fine, except when GetBooleanValue() is true, it sorts MyField1 as if it were text.