Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print field as it was in the detail but have to be on the page header 3

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
Hi
I have a report that display item in the detail section. For each Item that is printed in the detail section I have to display a field "Nist" that is in the item table. This field has to be printed in the page header

For example I would have this:

(Page Header)
Nist standard reference Materials: 3151, 3101a, 3103a, 3104a,3105a

(Detail)
Item1
Item2
Item3
Item4
Item5

(end of the report)
where:
the NIST of the Item1 is 3151
The NIST of the Item2 is 3101a
The NIST of the Item3 is 3103a
The NIST of the Item4 is 3104a
The NIST of the Item5 is 3105a


Is this possible to do that?
Thanks in advance
 
hi

you need to create a group section to be able to get this in the page header

cheers

pgtek
 
Sorry pgtek, but I don't know what you mean. I have to create a group to be able to see all my informations in the page header? And...group by what?
 
If you don't have too many instances to display, you could create a formula like the following and place it in the page header:

nthmostfrequent(1,{table.NIST}) + ", " +
nthmostfrequent(2,{table.NIST}) + ", " +
nthmostfrequent(3,{table.NIST}) + ", " +
nthmostfrequent(4,{table.NIST}) + ", " +
nthmostfrequent(5,{table.NIST}) //Add lines up to the maximum number of records to be displayed

Otherwise, I think you would have to do a subreport with a variable that accumulates the NIST values.

-LB
 
Does it have a way that I can know how many I have because it can change depend on the item. Sometime I can have 5 and sometime 9. As soon as I put nthmostfrequent(X,{table.NIST}) with a number (the X value in the formula) that doesn't exist it put the value of my formula to ''.
Thanks in advance
 
Okay I tried to do that but it gives me an error where I put the * in the code bellow. The error says "A number is required here" (instead of the variable i)

local stringvar memonist :="";
local numbervar i;
for i:= 0 to count({mods_rpt_certificateAnalysis8;1.uf_nist}) step 1 do
memonist = memonist + NthMostFrequent
*(i, {mods_rpt_certificateAnalysis8;1.uf_nist})
;
BTW, I'm with the Crystal Syntax
Any Idea how can solve this error.
 
You can place the following in the main report:

If count({table.Nist}) = 1 then {table.NIST} else
if count({table.Nist}) = 2 then
nthmostfrequent(1,{table.NIST}) + ", " +
nthmostfrequent(2,{table.NIST}) else
if count({table.Nist}) = 3 then
nthmostfrequent(1,{table.NIST}) + ", " +
nthmostfrequent(2,{table.NIST}) + ", " +
nthmostfrequent(3,{table.NIST}) else
if count({table.Nist}) = 4 then
nthmostfrequent(1,{table.NIST}) + ", " +
nthmostfrequent(2,{table.NIST}) + ", " +
nthmostfrequent(3,{table.NIST}) + ", " +
nthmostfrequent(4,{table.NIST}) else
"" //etc.

Otherwise, you could create a subreport that mirrors the main report, and place the following formula in the details section:

whileprintingrecords;
stringvar NIST;

NIST := NIST + {table.NIST} + ", ";

Then create a display formula and place in the subreport report footer and suppress all other sections of the subreport:

whileprintingrecords;
stringvar NIST;
left(NIST,len(NIST)-2);

Place the subreport in the main report header.

-LB
 
lbass
Thanks for your time.
I thought about to do
If count({table.Nist}) = 1 then {table.NIST} else
if count({table.Nist}) = 2 then
nthmostfrequent(1,{table.NIST}) + ", " +
nthmostfrequent(2,{table.NIST}) else
if count({table.Nist}) = 3 then
etc...
but I might have as many as 70. Do you think it have a way to do this with a while or a for?
for example
cpt = count(table.Nist)
While cpt <> 0 then
str = nthmostfrequent(cpt,{table.NIST}) + &quot;, &quot; +
do
I tried this but I get error about the syntax.
could you please tell me if I can do that and if so, the syntax. It would be very appreciated.
Thanks in advance
 
I don't think you can use a loop for a report header formula unless you are looping through parameters (which are available in the report header). In your formula, you are trying to evaluate details that are not yet available when the formula is printed. If NISTs were parameters, you could easily use a loop.

I think you must use a subreport if you have to place the results in the page header, creating the two formulas I mentioned earlier to get your desired results.

-LB
 
Wow!
It's working. I couldn't do this without you!
Thank you very much lbass!
 
I have a little problem
I use this code that lbass gave me :
whileprintingrecords;
stringvar NIST;
left(NIST,len(NIST)-2);

I got an error that says:
&quot;A string can be at most 254 characters long.&quot;
Does it have any other type of variable that accept much more characters than 254?
Thanks in advance
 
In thread 767-586991 Naith shows a formula that allows the display of up to 508 characters. His formula can further be adapted to allow display of 762 characters if you add another variable. The formula basically creates segments of 254 each which can displayed in individual formulas dropped into a text field. I've tested this out, so let me know if you need help. It looks like the maximum number of characters you would be working with would be about 490.

How to do it aside, I wonder how useful a display of 70 5-digit numbers in &quot;narrative&quot; form are going to be to whoever views the report, but I gather that this is the requirement, and so onward...

-LB
 
lbass,
I'm really sorry but I'm not good enought with Crystal Report to understand this code and to apply this to my code. I don't know what the Y and Z does and the //*//.
for now, I'm using this code that you gave me and I have no Idea how to merge this with the Naith's code.
Could you help me with that please.

If count({table.Nist}) = 1 then {table.NIST} else
if count({table.Nist}) = 2 then
nthmostfrequent(1,{table.NIST}) + &quot;, &quot; +
nthmostfrequent(2,{table.NIST}) else
if count({table.Nist}) = 3 then
etc...
 
If you can have a string up to 70*5, I don't think you need to make things more difficult for yourself by catering for any more than 508 characters. You can merge the two formulae lbass has referenced for you like this:

WhilePrintingRecords;
StringVar x;
StringVar y;

If count({table.Nist}) = 1 then {table.NIST} else
if count({table.Nist}) = 2 then
If length(x) + 5 > 254
then y :=
nthmostfrequent(1,{table.NIST}) + &quot;, &quot; +
nthmostfrequent(2,{table.NIST})
else x :=

nthmostfrequent(1,{table.NIST}) + &quot;, &quot; +
nthmostfrequent(2,{table.NIST}) else
if count({table.Nist}) = 3 then
If length(x) + 5 > 254
then y :=

...etc...

The new additions you'll need to make are in red.

If it's necessary for the NIST string holders to reset, then create formula with:

WhilePrintingRecords;
StringVar x := '';
StringVar y := '';

Display the variables where appropriate by creating two formulas, and placing them next to each other in a text box.

WhilePrintingRecords;
StringVar x; //the other formula should say 'y', not 'x'.

All the best,

Naith

 
okay
But Why &quot;+5&quot;? Where did you get your 5?
Thanks in advance
 
By reading this excerpt from lbass' last post.

&quot;I wonder how useful a display of 70 5-digit numbers in &quot;narrative&quot; form are going to be to whoever views the report&quot;

I haven't read this entire thread, I'm just assuming that 5 is the length of the field. If it isn't, then replace '+5' with 'length({field})'.

Naith
 
I've sent you report back with the adjustment for the larger field size.

I used the same theory as Niath's suggestions

I expanded your formula to create a second NIST list when the length of the first one gets to be above 230 characters long. I used 230 so that the field is 2 full lines. If I used a bigger number, the field wraps to a third line..

Name: {@NIST}
Formula:
whileprintingrecords;
stringvar NIST;
stringvar nist2;

if len(NIST)>230 then (nist2:=nist; nist:=&quot;&quot;) else nist:=nist;
NIST := NIST + {mods_rpt_certificateAnalysis8;1.uf_nist} + &quot;, &quot;;


I then created a second &quot;displayNIST&quot; formula.:

Name: {@displayNIST2}
Formula:
evaluateafter({@nist});
stringvar NIST2;

I then inserted an additional section in the subreports's Report footer and moved your DisplayNist formula here - I did this becasue of the possibility of the NIST2 being present. I inserted the displayNIST2 formula into the original report footer. I then conditionally suppressed the first report footer using: {@displayNIST2}=&quot;&quot;. This will suppess the section if the accumulating formula very gets to be 230 chacters long.




Mike
 
Wow!
Thanks to both of you guys!
Now I have to look at it to understand it and learn! :)
Thanks again!
 
Hi there
I have an error when I'm trying to call the report from my application..
But when I run the report to see the data (lightning) it works and doesn't give me any error message...???

I tried to call an empty report based on the same SP and it works.

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top