softend:software:crystalreport:storeandfetch:start

Using ‘Store’ and ‘Fetch’

Using ‘Store’ and ‘Fetch’ When using the ‘Store’ and ‘Fetch’ functions the variable is stored to a special variable in the main report and then retrieved in the subreport through a formula, similar to the following:

StoreNumberVar ("Test",1000)

and

FetchNumberVar ("Test")

Every time ‘Test’ is referred to, you have to repeat the ‘Fetch’ statement. Using shared variables eliminates this step. To pass a variable to the main report from the subreport in Crystal Reports version 7, 8 or 8.5, create a formula similar to the following:

  • “Storing” the data in the subreport:
WhilePrintingRecords;
Shared NumberVar Test:= 1000
  • “Fetching” the data in the main report:
WhilePrintingRecords;
Shared NumberVar Test;
Test

To pass a variable to a main report from the subreport in Crystal Reports version 7, 8 or 8.5 that uses dynamic field data, create a formula similar to the following:

  • Storing field information in the subreport;
WhilePrintingRecords;
Shared currencyvar x:= {LastYearsSales.Field}
  • Fetching the field data in the main report;
WhilePrintingRecords;
Shared currencyvar x;
x
  • Previously, if a ‘Fetch’ occurs before the ‘Store’ then an error is generated. shared variables do not operate in the same manner; a blank or zero value will be returned for the variable instead.
  • ‘Store’ and ‘Fetch’ does not allow the same fetch formula to be placed in the same section twice and a formula error would result. With shared variables this is no longer the case; the same variable may be shown multiple times in the same section. Known issues with shared variables
  • Crystal Reports version 7.0.x.192 does not pass a shared variable between multiple sections of the same type, if those sections break across pages. For example, if a subreport containing a shared variable is placed in Report Footer A and that same shared variable is then called in Report Footer B, the correct value will be returned as long as the two sections are on the same page. If, however, Report Footer A is on page 1 and Report Footer B is on page 2, the shared variable in the second report footer will always return the value of 0.
  • A variable value being summoned from a subreport will only be available to the section AFTER the section that CONTAINS THE SUBREPORT. This is because the subreport is the last object to be processed in a section and those values cannot be used until the section after.
  • softend/software/crystalreport/storeandfetch/start.txt
  • Zuletzt geändert: 2019/05/02 17:26
  • von 127.0.0.1