We would like the user to be able to select different printers and paper size for each report. This setting could be set up and saved once.
To do that, we can create a form as below
To do this, we first create a table called ReportNames.dbf. To create it use command
create table REPORTNAMES (ID int autoinc,REPORT Char(20),NARRATION Char(100))
In this we will enter all frx/lbl file names and their description. This table can then be included in the exe as it will be readonly.
The second table is printers.dbf.
create table PRINTERS (ID int autoinc,REPORTNAME Char(20),PRINTERNM Char(100),PAGESIZE int,PAGENAME Char(30),PORTRAIT L,OUTPUTTO int)
This is the table that saves the report settings of each report. This is to be placed in a subfolder of the user APPDATA folder. The folder should be in the PATH, if it is not the default folder.
I am enclosing reportsetup form. Running this form will open the report setup screen which will update the printers.dbf table. It uses 3 PRGs winapierrmsg.prg, EnumPrinterForms.PRG and winapisupport.PRG. All of them are sourced from http://www.berezniker.com
Printing of report
I have enclosed myclass.vcx that has myreport class. You use that to print the report.
To print a report give commands
The runreport method will check the printers.dbf for settings. If a record exists in printers.dbf, the frx file will be copied to the temp folder and updated with the settings. This updated file will be used to run the report.
Note: Since the myReport class calls the report, local variables declared by your code will not be visible to the report.