Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: select last "x" number of records in database Post Reply Post New Topic
Author Message
JennyLynn
Newbie
Newbie
Avatar

Joined: 07 Jul 2009
Location: United States
Online Status: Offline
Posts: 12
Quote JennyLynn Replybullet Topic: select last "x" number of records in database
    Posted: 28 Jul 2009 at 9:40am
Hey everybody! I need some help coming up with a selection formula that will only display the last 6 records from a database...

Long story aside, what I have is a crystal file using an excel file outputted from another Crystal report as its database, it has 5 columns, 4 with data (month, var1, var2, var3) and another column which I added which contains the record number 1 -> x (which is 15 at this point).

Since the number of records is dynamic I can't have a formula like {record} > 10 or something simple like that, I've tried a bunch of things but every way I've thought of uses a "WhilePrintingRecords" approach and therefore isn't criteria for a selection formula.

It seems like a simple request but crystal is making it hard for me and ruining my day (like always), any help would be greatly appreciated! THANKS~!!

~~~~Jenny Lynn
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Jul 2009 at 11:35am
Will suppression instead of exclusion work? Just remember that suppressed rows are still include in other summarizations.
 
You can conditionally supress your detail rows via a formula like:
RecordNumber <= Count ({tables.field that is on every row})-6
IP IP Logged
JennyLynn
Newbie
Newbie
Avatar

Joined: 07 Jul 2009
Location: United States
Online Status: Offline
Posts: 12
Quote JennyLynn Replybullet Posted: 28 Jul 2009 at 11:35am
nevermind, I found a workaround using the 'dateadd' function, this worked because one of my data fields was a date (well after using the cDate function, but that's additional information), the selection formula is:

{FIELD.NAME} >= DateAdd('m',-6,CurrentDate)


Sweet!

Big%20smileBig%20smileBig%20smileBig%20smile
Big%20smile
~~~~Jenny Lynn
IP IP Logged
JennyLynn
Newbie
Newbie
Avatar

Joined: 07 Jul 2009
Location: United States
Online Status: Offline
Posts: 12
Quote JennyLynn Replybullet Posted: 28 Jul 2009 at 11:50am
thanks for the help DBlank, that works too! Oh choices choices! LOL
~~~~Jenny Lynn
IP IP Logged
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.