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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advice on using Reports in my app 1

Status
Not open for further replies.

Jerim65

Technical User
Aug 8, 2010
99
AU
Being self taught I am still somewhat of a beginner in my VFP knowledge hence lots of questions to tek-tips forum - and thanks to all who have helped me.

I am recoding parts of my application and have got to the Reporting area.

I only have 4 discrete reports however I need to provide for A4 and US letter users.

Old scheme - which used to work

Reading forums in the past 5 years I decided to keep the report files out of the exe - copy the required report to my temp folder and adjust the papersize in the frx file. I used to test if the required report was in the application folder first and then test if the commonly filenamed 'myreport.frx' was present after my copy.

I then had common routines based on 'myreport.frx' to

-Create a form filling my app's screen
-Create a small window on the form but hidden (not hidden for me so I can see what's happening)
-Run the report in the small screen to get the number of pages - then run again in the full window preview so that I can add say Page 1 of 12 etc

However some weeks/months ago that system seemed to stop working so in a panic I changed the scheme.

New scheme

1 Defined a report for each particular paper size.

2 Included them in my app's exe.

3 I don't see how I can test for the required report but if they are in the project it shouldn't be necessary.

4 The code now shows the form, the small windowappears but (in the debugger) I see it stepping past the first Report Form command and then the second.

Is there anything in my new method which is not the correct way to do it?

Thanks

Coldan



 
Further to the above my report viewing code is

Code:
**Local myprintfile recovered from ini file
**test for myprintfile
If N = 1
	logging('Myreport present')
		oRepForm = Createobject("Form")
		With oRepForm
			.Caption = ''
			.WindowState = 2   && This will maximize the form
			.Icon =''
			.Name = ''
			.Show()
			nTotalPages = 0
			Define Window rptview From 1,1 To 20,20
				Acti Window rptview 

			Report Form (myprintfile) All
* the first run will get the number of pages
			nTotalPages = _Pageno
			Release Window rptview
			Activate Screen
			Report Form (myprintfile) Preview Window ;
				(oRepForm.Name) To Printer Prompt
Coldan
 
Hi Coldan,

Just a couple of points in partial answer to your question:

1. You no longer need to run an extra pass of the report just to get the number of pages. You can print "Page x of y" simply by putting an expression like this in the report:

Code:
transform( _PAGENO) + " of " + transform(_PAGETOTAL)

2. Like you, I need to support both A4 and US Letter in the same report, but I don't have two versions of the report. I just design the report so that it fits the width of A4 and the length of Letter.

You can then either programmaitcially modify the papersize in the FRX file on the fly (as you are doing), or simply rely on the user choosing a printer that defaults to their required paper size (which is what I do).

I have found this works well.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Mike,

That's the problem with grabbing 'snippets' from forums - it's not easy to find out that they are 'outdated' .. but still work.

Code modified..

Coldan
 
In addition to getting answers to specific questions here, you might get some benefit (maybe, maybe not) from looking over some of the free on-line (or download-able) tutorial videos for some of your more general questions.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top