Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Shared variables use the same memory block to store the value of a variable throughout
the main report and all of its subreports. Thus shared variables are even more general
than global variables. To use a shared variable, declare it in a formula in the main report
as in the following example:
Shared NumberVar x;
In order to use shared variables, the variable must be declared and assigned a value
before it can be passed between the main report and the subreport.
Global variables use the same memory block to store a value throughout the main report.
This value is then available to all formulas that declare the variable, except for those in
subreports. You declare a global variable as in the following example:
Global StringVar y;
You can also omit the Global keyword which creates a Global variable by default:
Local variables are restricted to a single formula and a single evaluation of that formula.
This means that you cannot access the value of a local variable in one formula from a
different formula.
Example
//Formula A
Local NumberVar x;
x := 10;
//Formula B
EvaluateAfter ({@Formula A})
Local NumberVar x;
x := x + 1;
Before using a variable in a formula, you must declare it. A variable can hold values of a
given type. The allowed types are the seven simple types (Number, Currency, String,
Boolean, Date, Time and DateTime), the six range types (Number Range, Currency
Range, String Range, Date Range, Time Range and DateTime Range) and variables that
hold arrays of the previously mentioned types. This gives a total of 26 different types that
a variable can have.
You can declare array variables by following the type name with the keyword Array.
You can assign values to elements of an array and also use the values of the elements for
other computations.
The Redim and Redim Preserve keywords can be used to resize an array if you want to
add extra information to it. Redim erases the previous contents of the array first before
resizing it whereas Redim Preserve preserves the previous contents.
Arrays are commonly used with For loops. The following example creates and then uses
the Array [10, 20, 30, ..., 100] using a For loop.
13. What is running Total? And how can you use in Details Section?
Running Total used to summarize the Field Value.
1) Summary: the Field to Summarize and the Type of Summary operation: Normally you
would select a numeric field or formula and SUM that field.
2) Evaluate: How often do you want to calculate this summary? Usually it’s every record,
but you also control less frequent calculations by selecting an evaluate on change of
group. We don’t recommend the use of "on change of field" as the sequence of your data
can cause this to go horribly wrong. Change of group is a lot safer, even if it requires the
creation of an extra group in your report.
3) Reset: When do you want to set the total back to zero? Is this a running total that
accumulates all the way through the report, or do you go back to zero on the change of a
group field?
If we Use the Running Total in Details Section, It will be modify the Result for each
Record
14. In Crystal Reports (CR), is it possible to display every nth record without indexing
the Database table?
For example, you have a report with 100 records but you only want to see every 25th
record. Your report connects to a database table that does not contain an indexed field.
1. Right-click on the details section and click 'Section Expert'.
2. Leave the check box cleared and click the 'X+2' command button next to 'Suppress
(No Drill-Down)'. The formula editor opens.
3. Enter the given formula: Remainder((recordnumber),25) <> 0
15. How do you display just the report file name on the report?
To display just the report file name on a report, Create a new formula similar to this:
StringVar Array File:=Split(filename,'\');
NumberVar i := Ubound(File);
File[i];
16. How can you suppress a blank sub report from displaying on the main report?
To suppress the blank subreport, complete the following:
1. In the main report, right-click the subreport object and click 'Format Subreport'.
2. Select the subreport Tab,
3. Check the checkbox of Suppress blank subreport.
17. How can you share sub report data with the main report of the Crystal Reports
Designer?
Using the shared keyword we can share the sub report data with in the main report.
For example:
1. In the sub report, create a @MainFormula formula similar to the one below:
WhilePrintingRecords;
Shared CurrencyVar myTotal := Sum ({Orders.Order Amount})
2. Place this formula in your subreport.
3. In the main report, create a formula that declares the same variable name:
WhilePrintingRecords;
Shared CurrencyVar myTotal;
myTotal
4. Place @MainFormula in a main report section that is beneath the section containing
the sub report.
5. Once you have verified that @MainFormula is returning the correct value from the
subreport, you can include this formula in other main report formulas, such as:
{@MainFormula}+ Sum ({Customer.Last Year's Sales})
6. Place this formula in the same section as @MainFormula, or in a section further down
on the report.
18. How can you evaluate this database field in formulas or record selection criteria to
return the expected result set?
A) STEPS TO CONVERT NULL FIELD VALUES TO DEFAULT VALUE FOR ALL
FIELDS IN CR
1. Click File > Report Options
2. Select the 'Convert NULL Field Values to Default' check box.
3. Click 'OK'.
B) STEPS TO EVALUATE THE NULL FIELD VALUES IN CR
1. Create formula or record selection criteria.
2. Use the IsNull function at the beginning of the formula or record selection criteria.
3. If applicable, specify a value or action if the IsNull function evaluates a null record.
19. Where do you find the 'Keep Together' options in CR and how do they affect your
report?
To locate the 'Keep Together' option for the different sections of the report, follow these
steps:
1. In the Section Expert, select the section.
2 Under the Common tab, select 'Keep Together' check box.
When the 'Keep Together' option is selected, CR keeps the entire instance of the
particular section on the same page.
20. How can you format occurrences of a specific word or character within a string
field?
1. Create Formula as @StringFormat
2. Place the below said Formula in @StringFormat
Replace( "Mohanbabu ", "babu", "<b>babu</b>")
3. Place the formula @StringFormat in Report, Right Click the formula and the Select
Format Field
4. In Paragraph Tab, Select HTML Text in Text Interpretation
5. It will Display the Result as Mohanbabu