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

Crystal Formula

Status
Not open for further replies.

computerman29651

IS-IT--Management
Aug 28, 2006
51
US
I need a crystal formula to calculate the next invoice number.

As of right now, I have the following formula:

PageNumber + {?Invoice Number} -1

What I need if a Sample ID (1234) continues for three pages with an Invoice Number 2560, I need the next Sample ID to have a Invoice Number 2561.

Right now the next Invoice Number is going to 2563.

I am using Crystal 10.
 
Try using a variable, something like this:
Code:
numbervar InvoiceNo;
if previousIsNull(table.groupfield) then
  InvoiceNo := {?Invoice Number};
else if ({table.groupfield} <> previous({table.groupfield})) then
  InvoiceNo := InvoiceNo + 1;
InvoiceNo;

"{table.groupfield}" is whatever field you're using to group by that determines what an invoice is. This should set the invoice number to your parameter value when you start processing and then increment it by one every time the group changes. You may have to add "WhilePrintingRecords;" or "WhileReadingRecords;" at the top of this formula to get it to work right (I haven't tested it.)

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
hilfy,

I had to modify the code just a little, but it worked perfectly. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top