Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFp 6 Using a case statement in a report field
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00339722
Message ID:
00339880
Views:
20
>>>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

Have your UDF return the value to display in the field. This eliminates the need to do anything about the .T. or trying to display a variable.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform