Showing posts with label CrystalReport Tips. Show all posts
Showing posts with label CrystalReport Tips. Show all posts

Sunday, 23 April 2017

Formula Size Restrictions in Crystal Report

For reference purposes, here are the size restrictions of the formula language:
  • The maximum length of a String constant, a String value held by a String variable, a String value returned by a function or a String element of a String array is 65,534 characters.
  • The maximum size of an array is 1000 elements.
  • The maximum number of arguments to a function is 1000. (This applies to functions that can have an indefinite number of arguments such as Choose).
  • The maximum number of loop condition evaluations per evaluation of a formula is 100,000.
  • Date-time functions modeled on Visual Basic accept dates from year 100 to year 9999. Traditional Crystal Reports functions accept dates from year 1 to year 9999.

Friday, 21 April 2017

Display/ Passing Subreport Value into Main Report in Crystal Report

When using a sub report, you may wish to pass a result (such as a computed field, summary, or running total) back to the main report. A shared variable can be used to do this as long as you understand the order in which the results are calculated.
To use a subreport value in the main report, you must calculate it first - that is, the subreport must appear "above" its use in the main report. If this does not work with your report structure, you may have to put an extra copy of your subreport in a higher section.
For example, place this in the main report header section:
Computed item:
 whileprintingrecords;
 Shared NumberVar x := 0;
Subreport:
 whileprintingrecords;
 Shared Numbervar x:= sum({yourtable.yourcolumn})
Color each of these items with white text and shrink to the smallest size possible. Do not use the "suppress" option, as this prevents the item from being calculated.

Adding watermarks to Crystal Reports

First step is to copy the watermark image to the Page Header section or in any section in which you want to locate your image. 
 If your report is already using the page header, you can add an additional page header by right clicking on the Page Header section and choosing Insert Section Below.

Once you insert the watermark image you may need to re-size it or re position it lower so that it is does not show up at the top (unless that is what you want).

Now go to Report > Section Expert, click on the Page Header (if you created a new section, it will be Page Header b) under Sections and check Underlay Following Sections on the Common tab.
Click OK and go to your report Preview

Your Report Taking Long time to load - Try this

Recently we had a problem with reports taking a long time to load. 
After much investigation by the Server Administrators we discover that it was because of the subreports, specifically subreports that were imported. What had happened was that a new server was setup and all the report files were copied across and the old server was removed. When the report was loaded it was looking to reimport the subreport, but because the original location did not exist any more, it took about 20 seconds before timing out. What we found was that there is an option under subreport format on the subreport tab to re-import the subreport when opening. By unchecking this option the problem was solved.

Restrict no Of Reports per Page

Limit the number of records per page in crystal reports: 

1 : Create the following formula and place in the page header:

WhilePrintingRecords;
NumberVar counter := 0
Create the following formula and place in the detail section:
WhilePrintingRecords;
NumberVar counter;
counter := counter + 1

2 : Use the Count Details formula to force the new page based on the necessary number of records.

3: Go to Format/Section and select the Details section.
Click on the X+2 button to the right of the "New Page After" option. Be sure not to place a check in the New Page After box. Once you click on the button, you will be placed in the formula editor. Enter the following formula:
{@CountDetails} = 10 //Enter the number of recorders that you will want displayed on each page

Dynamic Text "continue on next Page" when data goes more then 1 page

You probably know that Crystal Reports has a 'Keep the group together' option. When this option is enabled, CR will keep the group from breaking across pages where possible. However, since some groups might take up more than one page, there might be times when a page break within a group is unavoidable. There might also be times when you prefer not to enable the 'Keep the group together' option.
When a group overflows a page break, you can help your users by adding a group continuation message to the page footer, as shown in Figure 1.
Figure 1: A helpful message at the foot of the page
To create this message, all you need to do is to drop a simple formula into the page footer band. The formula will look something like this:
IF {Customer.Country} = NEXT({Customer.Country})
THEN {Customer.Country} + " continues on next page"
In this example, Customer.The country is the grouping field. The formula compares the value of that field in the current record (which is the last one to be printed on the current page) with its value in the next record (the first one to be printed on the following page). If the values are equal, the group will be split across the page break; in that case, the formula will return the required message. If they are not equal, the formula will return a null string so no message will appear.

Fundamental Of Crystal Report

Basic operations

When using the design tab, zoom to about 120 percent. This will make it easier to grab the 'handles' of the controls. The design and preview tabs have independent zoom settings, so changing the zoom in one of them won't affect the other.
To create more space for the report in the design tab, open the Options dialogue (on the File menu); on the Layout page, enable the 'Short Section Names' option. This will show an abbreviated version of the section name in the gray area to the left of the design area, thus leaving more space for the report itself.
Report layout
If you have a column of figures which include a currency symbol (such as £ or $), you will improve the appearance of the report by not showing the symbol against every figure. Instead, place the symbol either in the column header or next to the figure on the first row on each page (to do so, open the field's Format Editor, choose the Number tab, click on Customize, go to the Currency Symbol page and enable 'One symbol per page').
You can get some interesting visual effects by using the Wingdings font that comes with Windows. This font includes bullets, arrows, icons and other fancy characters. To insert one of these characters into a report, open the Windows Character Map applet, select Wingdings from the list of fonts, click on the symbol you want, click Select, and finally click Copy. This will place the symbol in the Clipboard from where you can paste it into a text object.

Performance

You probably know that you can place fields and other objects inside a text field. This is useful in mailmerge-style operations, where you want to merge a value from a database into a piece of text. However, this technique should be used sparingly - especially with large reports - as it can greatly slow down the previewing of the report (but it does not affect the speed of printing or exporting).
If you need to view or print a report based on a small subset of data (for example, if your database table has tens of thousands of records but you only want to see a few hundred of them), keep your selection criteria as simple as possible. In particular, avoid using Crystal formulae in the criteria. If the criteria include Crystal formulae or any other syntax that the database cannot understand, the database server will send the entire table across the network, which could take a long time.
Keep in mind that sub-reports can have a bad effect on performance. If performance is an issue, try to reduce the use of sub-reports as much as possible.

Formula Editor

If you have difficulty reading the text in the formula editor, open the Options dialogue (File menu), go to the Editors tab and choose a larger font size. You can also change the font (only fixed-pitch fonts are permitted here) and customize the syntax coloring. The choices you make here also affect the SQL Expression Editor.
If you want to prevent one or more lines of a formula from being executed but you don't want to delete them (for example, if you want to test the effect of not running part of the code), turn the lines in question into comments. To do so, type two forward slashes in front of the line(s) if you are using Crystal syntax; type a single-quote character in front of the line(s) if you are using Basic syntax. Either way, the code will be treated as comments and will not be executed. To restore the code, simply remove the slashes or the quote.
Going further, if you have a large block of code that you wish to turn into comments, highlight the block, then either press Alt-M or click the 'Comment / Uncomment Selected Text' button on the toolbar. Repeat the operation to remove the commenting.
For more advice on using CR, be sure to visit this site regularly.

Control Structures (Crystal Syntax) In Crystal Report : If Expressions (Crystal Syntax) in Crystal Report

Formulas without control structures execute each expression in the formula exactly once when the formula is evaluated. The expressions are...