We had an earlier question regarding printing reports, and we came up with the following solution. We added a routine to the library (the code follows), and a small form with a Print button and a Close Button. The code is given below.
To overcome the dialog error box problem, we added the following function to lib1.
Library Routine:
method OpenReport(orient String,rptName String)
var
repinfo ReportPrintInfo
prnOptions PrinterOptionInfo
tc tCursor
strReportName String ;// tmp handle to report name
rHandle Report ;// tmp handle to report being opened
f Form
endVar
if NOT rHandle.open(rptName) then
msgStop("Error opening " + strReportName, "Please make sure the report exists and try again.")
else
rHandle.menuAction(MenuPropertiesZoomfitWidth)
rHandle.MAXIMIZE()
showspeedbar()
endIf
rHandle.setTitle(rptName)
f.open("rpt_print")
f.rpt_name=rptName
f.orient=orient
;
endMethod
The form referenced in the library method consists of two buttons, Print Report and Close. The code behind the two buttons follows.
Print Report Button:
method pushButton(var eventInfo Event)
var
PrintInfo dynarray[] anytype
r report
endvar
Printinfo"PanelOptions"=PrintClipToWidth
PrintInfo"Name"=rpt_name.value
;PrintInfo"Orient"=prnLandscape
PrintInfo"ShowDialog"=true
r.print(PrintInfo)
endMethod
Close button:
method pushButton(var eventInfo Event)
var
r report
rname String
endVar
;// Validation or confirmation code, if any, should go here
;//
;// Close the form
;//
rname= rpt_name.value
if r.attach(rname) then
r.close()
endif
close()
endMethod
Finally, the following code was added to the buttons calling the reports where name.rsl is the report name.
mylib.OpenReport("prnLandscape","name.rsl")
There may be more elegant methods, but this works for us.