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!

Page Number in reports

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
AU
I have a custom container class I call superpreview, which has pdf viewer and a container I use to preview reports

The funny thing is, the report preview is not resetting the page number
So each time the preview is reloaded it increments the page numbers by the amount of pages
Even funnier, it seems to be storing the page number some where in memory, because if I close the forms, then open again, the page number has not reset
This only applies to this preview container. If I preview in a standard VFP report form then the page number is OK
I am using _pageno in the report to show the page number

Here is the code that I use to paint the report to the container:

Code:
	****************************************************************
	lcReport="AnnualReport_Ancil"
	LnOrion=1 && Landscape
	lcMethodname="previewreport"
	****************************************************************
	IF lcMethodname<>thisform.superpreview1.methodname && New Run
		thisform.superpreview1.methodname=lcMethodname
		thisform.superpreview1.firstrun=.t. 
	ELSE
		thisform.superpreview1.firstrun=.f. 	
	ENDIF 
	thisform.superpreview1.setreporttype(0)
	thisform.superpreview1.orientation=LnOrion
	thisform.superpreview1.setorientation
	rl=thisform.superpreview1.previewcont1.listenerref
	REPORT FORM &lcReport. OBJECT rl NORESET
	lcRec=rl.OutputPageCount
	thisform.superpreview1.previewcont1.totalpages=lcRec
	lcPAge=thisform.superpreview1.previewcont1.pageNo
	IF lcPage>lcRec
		lcPAge=lcRec
	ENDIF
	IF thisform.superpreview1.firstrun=.t. 
		lcPage=1
	ENDIF
	thisform.superpreview1.updatepagecnt(lcPAge,lcRec)
	* Render page 1 to the target:
	WAIT "" WINDOW AT 2,2 TIMEOUT .005
	rl.OutputPage( lcPage, thisform.superpreview1.Previewcont1, 2 )	
	****************************************************************

The references to page number provides the page number and count to a method in the container which displays "Page # of Total" in the preview container's tool bar
This is working OK

Any ideas people?



 
It seems you never reset superpreview1.firstrun, if you call the same way with the same methodname. Then you never reset lcPage=1
This logic seems odd. Why do you detect firstrun by a methodname and what is the method name?

Bye, Olaf.
 
Hi Olaf,
Above this code is what you can't see: the select statement/s and variables that are used in the report
To keep the variables in scope, this code goes in the form method (instead of putting it in the class)

Referencing by the method name enables the class to call the correct form method when reloading/updating the report

As I have quite a few and varied reports in this form,
lcMethodname<>thisform.superpreview1.methodname && New Run
resets the preview container so the first page is displayed when previewing a different report
Also, this way I can keep the preview on the same page when reloading/updating the report preview

lcPAge=thisform.superpreview1.previewcont1.pageNo
this variable changes when the mouse wheel is scrolled and is reset to 1 when the preview container is called from another form report preview method

I don't think that any of the above code referencing page number is contributing to the issue. The page numbers are displaying correctly in the tool bar
using this method:
thisform.superpreview1.updatepagecnt(lcPAge,lcRec)

Back to the original problem:
_pageno variable in the report field is not resetting even when the form is closed and reopened, its staying in memory











 
OK Its fixed

The NORESET causes the issue
REPORT FORM &lcReport. OBJECT rl NORESET

This works
REPORT FORM &lcReport. OBJECT rl


 
Ah yes, this explains why _pageno isn't resetted. I thought you only were talkling about lcPage and the previewcont1.pageNo. NORESET has that meaning.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top