Print Page | Close Window

Array Question, please help

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7932
Printed Date: 02 May 2024 at 11:34pm


Topic: Array Question, please help
Posted By: mvaughn
Subject: Array Question, please help
Date Posted: 06 Oct 2009 at 9:56am
I am trying to show a "disclaimer" in a formula field in the page footer of a report based of values in me detail section.  Currently I hace this in a formula field called GradeArray which I have placed in my detail section and suppressed so it doesn't print.
 
whileprintingrecords;
stringvar array GradeArray;
numbervar Counter;
if not ( mailto:%7b@Grade - {@Grade } in GradeArray) then
(Counter := Counter +1;
if Counter < 1000 then
(Redim Preserve GradeArray[Counter];
GradeArray[Counter] := mailto:%7b@Grade - {@Grade }))
 
 
What I need to do is  access the GradeArray in the footer and see if it equals
41S42, 41F42, 41H42 or 41X40.  I can have anywhere from 1 detail line to 50.  Am I building the array correctly and if so how do I access from the footer  in the formula field to show the text if any of teh values has been added to the array?



Replies:
Posted By: BrianBischof
Date Posted: 06 Oct 2009 at 10:24am
You can modify to array declaration to increase its scope. Using 'Global' will make a variable accessible throughout your report. Using 'Shared' will make it accessible to subreport (not relevent here, but good to know for the future). You could change your variable declaration to the following:

Global stringvar array GradeArray;

Note that you have to include this same variable declaration in every formula that needs to use the variable. If you leave it out, the formula won't recognize the variable.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: mvaughn
Date Posted: 06 Oct 2009 at 10:33am
Still not working, this is what i have now
FORMULA FIELD GradeArray------
whileprintingrecords;
Global stringvar array GradeArray;
numbervar Counter;
if not ( mailto:%7b@Grade - {@Grade } in GradeArray) then
(Counter := Counter +1;
if Counter < 1000 then
(Redim Preserve GradeArray[Counter];
GradeArray[Counter] := mailto:%7b@Grade - {@Grade }))
FORMULA FIELD Disclamier ---------
whileprintingrecords;
Global stringvar array GradeArray;
if "41S42" in mailto:%7b@GradeArray - {@GradeArray } then
'Note: 4140 products are difficult to weld. If the 4140 products on this quote are for a welding application, a qualified weld engineer should be consulted.'
For grins I added a formula field in the footer with this code
whileprintingrecords;
Global stringvar array GradeArray;
join(GradeArray,",")
 
when i run the report I get
41S42,01025 from the formula, so why doesn't my "Note" line show up?
 


Posted By: mvaughn
Date Posted: 06 Oct 2009 at 10:38am
Found it! in the disclaimer formula field, should be if "41S42" in GradeArray then.  Last part of the question if I need to look for other strings can I do
 
if "41S42" in GradeArray or "41H42" in Grade Array then
do something
 
or should I use multiple in statements?


Posted By: BrianBischof
Date Posted: 06 Oct 2009 at 2:04pm
yes, you can join the conditions into one IF statement.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window