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

Pass variable to report

Status
Not open for further replies.

Polly66

Programmer
Nov 3, 2001
42
AU
Hi everyone,

I have searched the faqs but cannot find any reference to my question.

I am new to the VFP (ver 9) report writer, having fashioned my own reports in Clipper for years using '@ say', but now realise that maybe there is an easier way and would like to give it a try.

What I want to be able to do is pass a variable, such as a date and other header type things to a formated report. This date, or the other header information isn't necessarilly the same data each time, hence my need to pass variables.

I am not sure if its permissible to ask two questions in the same thread, but I would also like to be able to query the printer before printing the report, for maybe such options as portrait/landscape etc. In my report there is no chance to set any printer attributes, the report just starts printing immediately the printer option is selected.

Thanks if anyone can help.

Bill Shepherd
 

Hi Bill,

The easiest solution is simply to create a private variable in the function, procedure or method that calls the report. For example:

Code:
PRIVATE MyDate
MyDate = <some date here>
REPORT FORM MyReport TO PRINTER
   && The report will be able to use MyDate

Re your second question, you can find out about the printer's attributes by calling PRTINFO(). But that won't tell you about landscape or portrait, as that choice is not specific to the printer. You can however find the sheet height and width.

Does that answer your questions?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bill,

In addition to Mike's advice, you can also call your report with the Preview clause.

REPORT FORM MyReport PREVIEW

This will allow the user to select a printer if there are more than one, and select printer settings.

Regards,
Jim
 
The easiest solution is simply to create a private variable

Mike's way is indeed the easiest. I prefer a more flexible approach which is to select the variables into a cursor together with the data from the table. Something like this:
Code:
Select Date() As myDate, ;
  HeaderText As myHeader, ;
  myTable.* ;
  From myTable ;
  Into Cursor myCursor
This has the big advantage that the cursor holds all the information that the report requires. I habitually do it this way so that I can give the user the choice of Print, Preview, Export to Excel, Export to file.

Geoff Franklin
 
Hi Mike, Jim and Geoff,

Thank you for excellent suggestions.

I still have a problem though with selecting printer attributes as the only print option available is the ptinter icon, and pressing that immediately starts the printer. So how do I select the printer options (from preview). Thank you all very much for your time.

Bill
 

Hi Don,

Thanks, that has solved the last bit of my problem.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top