Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to suppress a group without a specific number of records in detail

Status
Not open for further replies.

beacon5

Programmer
Dec 29, 2008
74
0
0
US
Hi,

[Crystal Reports 2008]

I'm writing a report and only want to return those groups that have more than two records in the details section.

My groups are:
- PatientID
- PatientName
- DataEntryDate (sorted by each day)

I've got two sets of record counting formulas (one is running total field, while the other set is three separate formulas). The formulas are:
- #RecordCount (running total field, summarizes PatientName for each record, resets on change of PatientID group)
- @RecordCount, @RecordTotal, and @RecordReset

The formula for @RecordCount (placed in Detail section):
Code:
WhilePrintingRecords;

NumberVar record;

record := record + 1;

The formula for @RecordTotal (placed in PatientName group footer):
Code:
WhilePrintingRecords;

NumberVar record;

record := record;

The formula for @RecordReset (placed in PatientID group footer):
Code:
WhilePrintingRecords;

NumberVar record := 0;

I've tried using...
Code:
@RecordCount > 2
&
Code:
#RecordCount
&
Code:
Count(MyTable.PatientName) > 2
&
Code:
Count(MyTable.DataEntryDate) > 2

...individually in the Group Selection formula, but it always throws a "This field can't be summarized until later" error message back.

I don't want to suppress just the detail records that have a count of 3 or greater...I want to select only the groups that have 3 or more detail records.

Thanks,
beacon
 
Why are you using running totals at all? If you right click on a recurring field in the detail section, do you get the correct count? Is so, you can just go to report->selection formula->GROUP and enter:

count({table.field},{table.group}) > 2

-LB
 
Hi LB,

I'm using the running totals for another purpose and was going to use it for this purpose too. When I couldn't get it to work with the running total field, I used the three formulas.

I got it to work based on your suggestion. I forgot that you can perform a count for a field within a group where the Count() formula has two arguments. Most of the times I use the Count() formula, it's only for a single field and the group doesn't matter.

Thanks for your help,
beacon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top