Showing posts with label CRYSTAL REPORTS. Show all posts
Showing posts with label CRYSTAL REPORTS. Show all posts

Tuesday, June 11, 2013

CRYSTAL REPORTS - SHOW NUMBERS IN WORDS - IN LAKHS & CRORES FORMAT

We can use toWords() Function in crystal reports to show numbers in words. But it does not supports South Asian numbering system (in Lakh & Crore). The following Crystal reports function helps to show amounts in Lakh & Crore.

Create a new formula field and place following script in it.

numbervar pVal:=0;
numbervar Amount:=0;
numbervar frPart:=0;
stringvar InWords :="Rupees ";

Amount := 10000000.75;    [Assign your amount here]

if Amount > 10000000 then pVal := truncate(Amount/10000000);
if Amount = 10000000 then pVal := 1;

   if pVal = 1 then
        InWords := InWords + " " + towords(pVal,0) + " crore"
   else
        if pVal > 1 then InWords := InWords + " " + towords(pVal,0) + " crores";


    Amount := Amount - pVal * 10000000;
    pVal := 0;
    if Amount > 100000 then pVal := truncate(Amount/100000);
    if Amount = 100000 then pVal := 1;
  
   
    if pVal = 1 then
        InWords := InWords + " " + towords(pVal,0) + " lakhs"
    Else
        If pVal > 1 then InWords := InWords + " " + ToWords(pVal,0) + " Lakhs";

        Amount := Amount - pVal * 100000;

        if Amount >= 1 then InWords := InWords + " " + towords(truncate(Amount),0);

        frPart := (Amount - truncate(Amount)) * 100;

        if frPart > 0 then
            InWords := InWords + " and " + towords(frPart,0) + " paisa only"
        else
            InWords := InWords + " only";

ProperCase(InWords)
     


Tuesday, May 7, 2013

To Pass Main Reports Parameter Field Value to Subreport (Crystal Reports)


Step-1 Right click on sub report container in main report, Select -> Edit Sub Report
Step-2 Create the parameter in sub report (if not exists)
Step-3 Return to Main report
Step-4 Right click on sub report container once again and select -> Change sub report links..
Step-5 Select the parameter field (defined in master report) from 'Container Report fields to link'--> Available fields  (shown in left hand side), and add it into 'Fields to Link' list box. Select the newly added field. Select the sub report parameter field name from 'Subreport parameter fields to use' combo box.

DONE..!!!