SMcHugh
SMcHugh

Reputation: 36

crystal reports detail display order in same order as user entered parameters

Crystal Reports Question. I have a user who is entering in a list of invoice numbers into a parameter. She wants to display the invoice number and other information in the order that she entered the list of invoice numbers into the parameter. Is this possible in Crystal Reports. I have seen a number of ways to do this in SQL, but not in Crystal Reports.

Below is a simplified version of the current SQL query used as a command in Crystal Reports. The paramater {?InvoiceNumber} is a CR array parameter.

SELECT
     CUS.ACCOUNT,
     CUS.ADDRESS,
     CUS.COMPANY,
     INV.INVOICE_ID
FROM
     INV
INNER JOIN
     CUS
     ON INV.ACCOUNT = CUS.ACCOUNT
WHERE
     INV.INVOICE_ID IN {?InvoiceNumber}

Upvotes: 1

Views: 377

Answers (1)

heringer
heringer

Reputation: 3188

Try this:

  1. Create a formula in Crystal Reports to find the invoice index in the parameter array. Let's name it IndexOf and the code could be:

    numbervar size:=ubound({?AccountNumber});
    numbervar position:=0;
    Local NumberVar i;
    For i := 1 To size Do
    (
        if {?AccountNumber}[i] = {INV.INVOICE_ID} 
        then position:=i;
    );
    position; //return
    
  2. Create a group by IndexOf.

Here is a shared RPT file working with this.

Upvotes: 1

Related Questions