Showing posts with label formula fields. Show all posts
Showing posts with label formula fields. Show all posts

Crystal Reports : Convert number var to HH:MM in crystal reports


Open the formula field editor in the report, right click on the report custom functions and click on New




The editor window will be opened. Paste the below code in the editor overwriting the text in it.


Function (numbervar Mins);
(
     stringvar tmp := totext((Mins/60 - (truncate(Mins/60))) * 60 ,0);

     select len(totext(truncate(Mins/60),0)) 
     case 1:
               '0' +  totext(truncate(Mins/60),0) + ':' + select len(tmp)
     case 1:
               '0' + tmp
     default:
               tmp
     Default:
              totext(truncate(Mins/60),0) + ':' + select len(tmp)
          case 1:
                     '0' + tmp
          default:
                     tmp;
)




The above code accepts a numbervar parameter. and returns a string

Your function will be created with the name you give 
As shown below i have two functions created.



You can call this function in your formulas and get a string value in return.

Crystal Reports : Convert number var to decimal in crystal reports

Open the formula field editor in the report, right click on the report custom functions and click on New





The editor window will be opened. Paste the below code in the editor overwriting the text in it.


Function (numbervar Mins);
(
       numbervar toseconds;

      toseconds := Mins * 60;

      stringvar todecimal := totext((toseconds / 3600),0);

      todecimal;

)



The above code accepts a numbervar parameter. and returns a string

Your function will be created with the name you give 
As shown below i have two functions created.



You can call this function in your formulas and get a string value in return.






Crystal Reports : Start group in new page.

How to get this thing done?
First of all , Right click on the section [Group] that you want to start in a new page each time.



Select Section Expert as below

The below window pops up and then click on the paging tab and then click on the button with the [x-2] like image.


Write the below formula.




This should bring up your records in new page for each group.



You can also control this action by passing a formula within this formula, and checking it with a value  for example.

Here @NewPage is a formula field i have added with the default value "1" you could pass this formula field with another value  like "0" . and when it is combined with a "and" condition within the if it becomes a boolean condition.