>>Hi All,
>>
>>Is it possible to use a case statement in the expression of a field in a report form?
>>
>>This works in a third party report writer (R&R):
>>
>>case(section,"A","Mares Foaled","B","Mares Bred","C","Mares Treated","D","Absentees","")
>>
>>If I enter this in the expression box in a field added to the vfp report designer and, then run the report, I get a "case.prg not found" error message.
>>
>>I guess I could use iif's in multiple fields but it seems easier to use the case.
>>
>>Any help would be appreciated.
>>
>>Thanks,
>>
>>Jim Harvey
>>jharvey@netrax.net
>
>At least two possibilities, one use a nested iif(), the other write a udf() and call it in the report writer. In the textbox instead of putting the field name you just put the udf as in - getthisdata().
John,
Thanks for the help.
I created a .prg called "secorder.prg" with this code:
do case
case section = "A"
store "Mares Foaled" to msection
case section = "B"
store "Mares Bred" to msection
case section = "C"
store "Vet. Report" to msection
case section = "D"
store "Absentees" to msection
otherwise
store " " to msection
endcase
Then I added a variable to my report form called "msection" and made the 'value to store' = secorder()
After testing it appears that I need to add two fields to my report form, one for msection, and one for secorder().
If I don't, instead of seeing "Mares Foaled", "Mares Bred", etc., etc., I get .t. as the value on the report.
Do I need to keep both fields on the report? I could move the field containing secorder() in the expression to the side, as it's the one showing ".t." as its result, and make it narrow so the .t. doesn't appear to noticeable, but that's not really the best solution.
Am I still missing something?
Thanks,
Jim