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!

Printing Page Number of Main Report in Subreport 1

Status
Not open for further replies.

Minch

MIS
Mar 17, 2011
36
US
Hello,
I want to display Page Number of Main Report in Subreport.

I tried to use Shared Variable in this way

In main report, I created a formula called "PageNum"
Shared NumberVar PageNum
PageNum:= PageNumber

and in subreport, I'm calling it by
Shared NumberVar Pagenum

However, what it does is it copies the whole formula,
so it prints the page of subreport rather than main report.
Please help!
 
What are you trying to do with the main report page number once it is in the sub? In what report section is your main report formula placed? In what report section are you calling the variable within the sub? If the sub is in the report footer, it will carry the value of the page number of the first page where the sub is displayed.

-LB
 
I have a subreport placed in report footer.
What I'm actually trying to do is suppress a field in the subreport based on the page number of main report so that it does not mess up the graphic
 
What does the page number of the main report have to do with this? Please provide more explanation, e.g., where is the graphic located within the subreport? In what way does the field affect the graphic? Why do you think using the main report page number might help?

-LB
 
Actually, let me try something else and get back to you.
Now I think about it. I don't think i need to use the subreport thingy
 
OK, LB
My plan failed.

I'll explain in little more detail.
I have PAGE HEADER section with textbox used as column lines, so that if there are less than 10 rows of record, textboxes in that section gets display.
This gets used only once in Page 1 because from page 2. the height of section becomes same.

If there are more than ten rows, column lines (again textbox) in DETAIL SECTION will be displayed instead of lines in page header (Meaning, if there are less than 10 rows of record, these lines will be suppress).

Now I have subreport in a report footer.
Subreport footers also has textbox lines in the detail section,
so that the rows have identical line as ones in the detail (meaning it should be aligned)

What happens that once there are one items in detail, this gets pulled to the first page, where it overlaps with the lines in the page header, leaving the section really messy.

I want to prevent this by suppress the lines in the subreport if the main page # is 1, meaning it will not the displayed, if the data in subreport is sitting on page one, the lines in page 1 won't displayed..
 
In the main report, add the shared variable to the page header, so that the current number is above the subreport when it executes later in the page. You can suppress the formula.

Add a formula referencing the shared variable in the first section of the subreport (RHa):
whileprintingrecords;
shared numbervar pagenum;

You can suppress the formula and format the section to "suppress blank section". Then you can format the text box (which MUST be in a lower subreport section) using a suppression formula like this:

whileprintingrecords;
shared numbervar pagenum;
pagenum = 1

This will suppress the box if the sub executes on the first page of the main report. However, note that the shared value will be constant for the length of the subreport, regardless of how many pages it runs.

-LB
 
OK.. so...
1)In page header
Shared NumberVar PageNum;
PageNum := PageNumber

2) SubReport Header
WhilePritingRecords
Shared NumberVar PageNum;

3) Textboxes
WhilePrintingRerocds
Shared NumberVar PageNum;
PageNum = 1
 
I did it, but it's not working.
Did I do something wrong?
 
You'll have to be more specific about exactly what you did, e.g., where you placed each formula. I tested this, and it worked.

-LB
 
Uh.... OK...

* SubReport is located in Report Footer A

1) Main Report, Page Header A
Shared NumberVar PageNum;
PageNum := PageNumber

2) SubReport, Report Header
WhilePritingRecords
Shared NumberVar PageNum;

3) Textboxes, Detail, SubReport
WhilePrintingRerocds
Shared NumberVar PageNum;
PageNum = 1

 
You would select the text box->right click->format->suppress->x+2 and put Formula #3 there. But after rereading, if you want the text to return after page 1 of the sub (and I think this means after row 10), you should add a reset formula created in the field explorer to the sub detail section (not the formatting area):

whileprintingrecords;
shared numbervar pagenum;
if recordnumber > 10 then
pagenum := 0; //make sure the colon is there

-LB
 
OK... maybe there is problem with my formula let me create simple report of what i'm trying to do and post up here.
I already right-clicked, format and suppress x + 2 and put formula there (i've done that since the beginning..), but it's not working..
 
1) Page Header A in Main Report
Shared NumberVar PageNum;
PageNum := PageNumber

2) Report Header in SubReport (Located in Report Footer in Main Report)
WhilePritingRecords
Shared NumberVar PageNum;

3) Text Object in Detail Section, in SubReport (Located in Report Footer in Main Report)
WhilePrintingRerocds
Shared NumberVar PageNum;
PageNum = 1
 
As far as I can see is that
in SubReport, page # stay as 1, even though that portion is part of page 2.

Part of my Subreport is sitting on Page one while other one is page 2.

So I want textbox sitting on page 2 to show the line, but it's not doing that
 
Your is right, theoretically, but it is just not happening in my report.
I decide to go alternate.
Thank you for your help though
 
I think you have missed my point. From the beginning I said that the page number would remain the same throughout the subreport. In my last post, I said you need a reset formula that you create in the field explorer and place directly in the detail section (you can reset it). This will change the value of the pagenumber within the subreport, so that after the first 10 records in the sub (where I think you need the suppression), the suppression will no longer occur. If you need suppression for the rest of the first page, you just need to change the 10 to the number of records that can display on the first page.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top