Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: CR Processing Engine Post Reply Post New Topic
<< Prev Page  of 2
Author Message
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 17 Dec 2012 at 3:54am
Try this:
 
{@PiorYear}
//If the donor has more than one donation date
If not PreviousIsNull({donor group field}) and Previous({donor group field}) = {donor group field} then
Year(Previous({CnGf_1.CnGf_1_Date}))
else //default to current year if there is no previous record
Year({CnGf_1.CnGf_1_Date})
 
It's not working for the first record because the previous record is null.
 
-Dell
IP IP Logged
freebird40CR
Newbie
Newbie


Joined: 28 Nov 2012
Online Status: Offline
Posts: 9
Quote freebird40CR Replybullet Posted: 19 Dec 2012 at 5:27am

Local NumberVar PreviousGiftYear := Year(Previous({CnGf_1.CnGf_1_Date}));
Local NumberVar GiftYear := Year({CnGf_1.CnGf_1_Date});
Local NumberVar YearDiff;

WhilePrintingRecords;

//If the donor has more than one donation date
If not PreviousIsNull({CnBio.CnBio_SortKey}) and Previous({CnBio.CnBio_SortKey}) = {CnBio.CnBio_SortKey} then
    PreviousGiftYear
else //default to current year if there is no previous record
    GiftYear;

YearDiff := GiftYear - PreviousGiftYear;

Unfortunately, it is picking up the last record in the previous group.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 20 Dec 2012 at 8:08am
Try this change:
Local NumberVar PreviousGiftYear := Year(Previous({CnGf_1.CnGf_1_Date}));
Local NumberVar GiftYear := Year({CnGf_1.CnGf_1_Date});
Local NumberVar YearDiff;

WhilePrintingRecords;

//If the donor has more than one donation date
If not PreviousIsNull({CnBio.CnBio_SortKey}) or Previous({CnBio.CnBio_SortKey}) = {CnBio.CnBio_SortKey} then
    PreviousGiftYear
else //default to current year if there is no previous record
    GiftYear;

YearDiff := GiftYear - PreviousGiftYear;

-Dell
 
IP IP Logged
<< Prev Page  of 2
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.