• Status: Solved
• Priority: Medium
• Security: Public
• Views: 6429

# How do I get a count in Crystal Reports til the report reads all of the records. I need a loop function in Crystal Reports see inside

i am developing a Crystal Report and I want to be able to provide the following function, but I need help writing this function in VB.

groupcountnumber = 0

if( {Command.Status} <> "PRS" or {Command.ACTIONCODE} = "ZDEC" or {Command.ACTIONCODE} = "ZCLO") Then

groupcountnumber = groupcountnumber +1

End If

Formula = groupcountnumber

What I need is for a loop to read through all the records and keep on counting with an increment of 1 as long as the above If statement is accomplished.  I am not sure exactly how to write out this function in VB for Crystal Reports.  Can anybody help?
0
VBBRett
• 2
1 Solution

Commented:
You can't loop through the records in Crystal.  There are several methods to accomplish this.

I like to use running totals
Display the FIELD INSERT popup
Click the RUNNING TOTALS tab
Click NEW (may have to right click)
Name countGroup
Type - Count
Field - Pick one (I tend to use the index field)
Execute - Use a formula
( {Command.Status} <> "PRS" or {Command.ACTIONCODE} = "ZDEC" or {Command.ACTIONCODE} = "ZCLO")
Reset - Never (or if this is a group count - on group change)

Put the field in one of the footer sections

Another way is to use formulas
Name - DeclVars
Formula
WhilePrintingRecords;
Global NumberVar groupcountnumber := 0;

In the detail section
Name - CountRecords
Formula
WhilePrintingRecords;
Global NumberVar groupcountnumber;

if( {Command.Status} <> "PRS" or {Command.ACTIONCODE} = "ZDEC" or {Command.ACTIONCODE} = "ZCLO") Then
groupcountnumber = groupcountnumber +1

In the footer
Name - DispCountRecords
Formula
WhilePrintingRecords;
Global NumberVar groupcountnumber;
groupcountnumber

mlmcc
0

Commented:

mlmcc
0

Author Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.