I have a report and on the PageHeader I have a field called Job Number There are probablbly about 5 Job numbers as I have put it in the page header it's only showing the first number is there anyway I can display all the numbers in the Page Header.
You can only represent this information in the page header if you precede the page header section with a subreport. In the subreport you would stack the job numbers in a shared variable, and then return then in the main report page header.
You could also have the subreport display the job numbers, though this would mean a detail line that repeated five times. It depends on whether you want them just once or on every page header.
If it's every page header, Naith's method is better. If it is just once, show them as a subreport display in the Report Header.
Thanks for you help. I have created the sub report and this works. The only problem I have now is that the Job Numbers and listed going down instead of across ! Any more suggestions
If you used the shared variable option, you would be able to place the shared variables anywhere in the main report. The idea would be to suppress the subreport from showing at all.
yes....run the subreport suppressed in the report header so it only runs once. Using Shared variables such as suggested by Naith would allow you to display the numbers anytime you want after the subreport has been run.
You can arrange the job numbers horizontally in one formula such as the following:
for pointer := 1 to ubound(Jobnumbers) do
(
If JobNumbers[pointer] <> "" then
result := result + " " + JobNumbers[pointer] + ",";
);
result := left(result,len(result)-1); //gets rid of last ","
result;
IF YOU HAVE REASON TO BELIEVE YOU WILL EXCEED 254 CHARS
THEN YOU WILL HAVE TO ADD SOME MORE CONDITIONS TO THIS FORMULA
*******************
In your subreport you would save the Job Numbers this way
In the report Header set an Initialization statement(suppressed)
@Initialize
WhilePrintingRecords;
//add 50% more job numbers to the array than you expect
StringVar array JobNumbers := ["","","",""....,"",""];
numberVar pointer := 0;
Then in the detail section place an accumulation formula to get the numbers
//A test to see if you exceeded the array size
If pointer >= ubound(JobNumbers) then
JobNumber[ubound(JobNumbers)] := "** Job Numbers Missing **"
else
JobNumber[pointer] := {table.jobnumber};
The [n] part instructs which part of the array to return. In this case, the first one. If the number of job numbers is variable, use the UBound function so that you don't fall over.
i.e.
WhilePrintingRecords;
Shared StringVar Array JobNumbers;
If UBound(JobNumbers) > 2
Then
JobNumbers[3]
The UBound just makes sure that there actually is a third component before you call it.
for pointer := 1 to ubound(Jobnumbers) do
(
If JobNumbers[pointer] <> "" then
result := result + " " + JobNumbers[pointer] + ",";
);
result := left(result,length(result)-1); //gets rid of last ","
result;
*********************
@Initialize
WhilePrintingRecords;
//add 50% more job numbers to the array than you expect
Shared StringVar array JobNumbers := ["","","",""....,"",""];
numberVar pointer := 0;
Then in the detail section place an accumulation formula to get the numbers
//A test to see if you exceeded the array size
If pointer >= ubound(JobNumbers) then
JobNumber[ubound(JobNumbers)] := "** Job Numbers Missing **"
else
JobNumber[pointer] := {table.jobnumber};
You don't declare all variables "shared" .... only the ones that you want to pass between main report and subreport(s)
Thanks for your help. I can't get the formula to bring back any results.
I am getting Error A Subscript must be between 1 and the size of the array
Any more Idea's I would be greatfull.
I have in the page header of the sub report:-
{@Initialize}
WhilePrintingRecords;
//add 50% more job numbers to the array than you expect
StringVar array JobNumbers := ["","","","","",""];
numberVar pointer := 0;
//A test to see if you exceeded the array size
If pointer >= ubound(JobNumbers) then
JobNumbers[ubound(JobNumbers)] := "** Job Numbers Missing **"
else
JobNumbers[pointer] := {JCJOBS.JOB};
for pointer := 1 to ubound (JobNumbers) do
(
if JobNumbers[pointer]<>"" then
result := result + "" +{JCJOBS.JOB}[pointer] +",";
);
result := left (result,len(result)-1);//get rid of last line
result;
Subreports do not have page headers. Where do you really have these formulas placed? Pay particular attention to where Ngolem told you to place the formulas, otherwise they will not work.
You're getting this error because you have not declared the JobNumber array as a shared variable every where you need to. You've only declared it as shared once.
By treating the variable like this, what you've actually done is create two variables called JobNumber - one shared and one that isn't.
You don't want two, you want one. So, prefix the declaration of JobNumber with Shared every time you call the variable - like you have in {@CollectJobNumbers}.
Thanks I have the data showing in the subreport now. In the details section @DisplayJobNumbers shows to rows the fiest row with one job number and the second row with two job numbers I only need the second row. Also I am sorry to be a pain but I will be using this a lot. How can I show the results in the main report. I have inserted the subreport into the main report and I see see the results but I would like to insert the formula only if at all possible.
No pain at all. It's important that you get this right, and understand why you're doing things the way you are, so feel free to ask as much as you need to.
Let's assume that you have the subreport placed in your Report Header. The idea is that anywhere after the Report Header section, you should be able to insert a formula like:
This you place in your main report - but remember - after the Report Header section. Now, if the JobNumbers array has been populated from the subreport like ("12","13","14","15", what this formula will display is "14". Because the [3]rd component of the array is 14.
Similarly, if you want to display the 2nd component in your main report, then you create another formula stating:
Hmmm...this application is changing....or is it the way I read it.
I thought that you wanted to collect the Job numbers in the Subreport then display the string of numbers in the main report...in a group header.
But as Naith said you can create other formulas to display a single or all Job numbers.
However to choose a single Job Number and know what you are choosing would be tricky...but then you are normally doing that through your manin report yes?
I though you just wanted a list of them to appear in a group header .....
Actually, this is a fair point. It does sound, in your last post, like you're talking about grouping on jobnumbers meaning to display the information in the group footer as opposed to the details section.
The fix offered to you was intended to allow you to display all your jobnumbers separately in your main report page header. It now sounds like what you need to do is group on your jobnumbers - as this will stop you getting duplicate rows. You will not be able to group on a shared variable.
I am sorry for the confusion. I actually thought I would need to do this in a subreport due to the relationships in the report. I have one project number to 3 jobs numbers in the report header I put the Project Number in which is OK. I then put the Field Job Number in but it only show me the first one. I would like to see a list of job numbers in one field. I do have the 3 different job numbers in the details section of the report.
Thanks for all your help.
All your subreport should be doing is building the JobNumbers array. The subreport shouldn't even be displayed - because you want to list the numbers horizontally, as opposed to vertically, right?
So, you suppress all the subreport sections, and leave it in the report header.
All the displaying is handled in the main report. Use these formulas:
in your main report. Now, as long as these formulas are placed after the section that the subreport has been placed in, you should be able to see each one of your jobnumbers.
When I change the number to 2 it dosn't work the field is blank.
I think it's falling over here.
//A test to see if you exceeded the array size
If I put the Field {JCJOBS.JOB} it will show the next job number if I take it out it will show your job numbers missing so I think that the array I have made is not making them into 1 and 2 and 3 ect.
//A test to see if you exceeded the array size
If pointer >= ubound(JobNumbers) then
JobNumbers[ubound(JobNumbers)] := //"** Job Numbers Missing **"
else
JobNumbers[pointer] := {JCJOBS.JOB};
Okay, so we've narrowed the problem down to the fact that the array doesn't seem to be stacking the numbers for you.
Let's try a simple alternative, and see what the impact is for you.
The formulas inserted in the subreport are in red. The formulas for your main report are in blue.
In your subreport:
[ul][li]Group by {JobNumber}[/li][li]In the Group Footer, place this formula:[/li][/ul] WhilePrintingRecords;
Shared Stringvar JobNumbers1 := JobNumbers1 + {JobNumber} + "*";
Whilst in the subreport, hit the lightning so you execute the subreport on it's own. Check how many jobnumbers are returned. If there is only one, then the original formula was already working for you. If there are more than one, than one, suppress each section of the subreport if you have not done so already and return to the main report.
In your main report, right click the grey area to the left of the Report Header section that the subreport is placed in, and select Insert Section Below. Right click the grey area to the left of the new section, and suppress it.
Insert the following formula into the new section.
WhilePrintingRecords;
Shared StringVar JobNumbers1;
StringVar Array CutArray := [""];
Now, in the section of your main report where you want to jobnumbers displayed, create and place the following:
//{@Formula to display 1st JobNumber}
WhilePrintingRecords;
Shared StringVar JobNumbers1;
StringVar Array CutArray;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.