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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic formula / variable question

Status
Not open for further replies.

Pete56

Programmer
Aug 29, 2001
39
US
I have the following function:

Global Numbervar nRecords;
nRecords := nRecords + 1

When I display it in the detail line it always displays 1.

Why doesn't it increment?
 
Try:

Whileprintingrecords;
Numbervar nRecords:= nRecords + 1;
nRecords

A global is only required when passing values between reports (main and subreports).

-k
 
You would get more help if you provided

1. Crystal Version
2. Database and connectivity
3. Examples of the data
4. Expected output

What are you trying to achieve with the formula?

Depending on what you are counting, you can use either the summary or running total function.
 
I think synapsevampire meant that Global is optional in the declaration line. If you don't specify the scope, Global is assumed.
Shared is only required when passing between a report and a subreport.

The "WhilePrintingRecords" that was provided by sv is what will give you the result you want.

~Brian
 
thanks, got it - didn't have the Whileprintingrecords.

I was just trying to understand why my variable value was not passing between functions.

What I am really trying to do is this:

Have a simple file of patient names, status and date, like
Joe, 1/1/2003,active
Joe, 2/1/2003,hold
Joe, 3/1/2003,active
Susan,1/1/2003,hold

Given a date (say 2/10/2003), list and count the patients who were active. I need to create a group with the patient info (and I relate back to the patient file) include only the patients who are active at that time by looking at the status value in the record immediately before the paramater date entered when the report was run.

Crystal reports 10

In the above example, if you ran for 2/10/2003 you would get no records, if you ran for 1/10/2003 you would get Joe's record.

It's basic but I'm building on this, relearning variables / formulas after not working with them for awhile. Any direction is appreciated. The Whileprintingrecords solved the first problem.

Thanks.
 
In the select formula, select all records less that your parameter date. Group by patient id. Sort by date. Suppress the detail section. In group footer for patient print the info. Suppress the patient group footer if status <> "active". I'm not sure how your count of nrecords fits into all of this.

MrBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top