Monday, February 20, 2012

Issue displaying data

I am a Crystal novice (to say the least) and I am trying to write a report that is presenting some problems. Our company sells memberships to our association and some people have multiple memberships. I need to create a list of all of these people with their memberships listed in columns next to their name. Since each membership is a different product I am having difficulty since it lists the member with all of information for each product. for instance I will group it by the ID# and ge tthe following results:

00001
Mike Smith company name address administrative
Mike Smith company name address business

I need it to display like this:

00001
Mike Smith company name address administrative business

I am not sure how to merge to the two records so that it only displays the personal information once with the two different memberships he purchased.

Does anyone have any ideas?

Thanks.My suggestion - don't use the details section to print stuff, I pratically never do.

Ensure your innermost group is the level at which you want to display data (i.e. the person level)
Have a formula in the details section to build up the string you want to display
Suppress the details section
Have another formula to return the string, and put this in the group footer
Have a formula in the group header to initialise the string

Your example currently shows each person record with some common details ('Mike Smith company name address') so I assume it doesn't matter which detail record you get this from. If so, your formula just needs to build up the 'administrative business ...' bit and you can display the common stuff directly in the footer from the last record in the person group.

Not knowing how many 'detail' sections you'll iterate through, you just need to ensure that your formula on the group footer is wide enough to display all the data, or set its 'can grow' property so that it will span multiple lines if necessary.

So, something like:

group header formula:

whileprintingrecords;
stringvar membershiplist := '';

details formula

whileprintingrecords;
stringvar membershiplist;
if membershiplist <> '' then
(
membershiplist := membershiplist + ' ';
)
membershiplist := membershiplist + <column>;

group footer formula:

whileprintingrecords;
stringvar membershiplist;
//return the variable
membershiplist

By the way, I've not put this code into Crystal, so you'll have to excuse me for any typos or missing semicolons, but it should get you on your way.

No comments:

Post a Comment