Subject |
Re: Preview.wfm and report printing |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Mon, 30 Oct 2023 17:21:08 +0200 |
Newsgroups |
dbase.getting-started |
On 2023/10/30 14:51, trevor wrote:
> Thanks for the reply. Seeding dates to the report form indeed is OK,
> opens and should work.
I assume you have added the parameters to the query in the report and
supplied the parameters with dummy dates so that double left-clicking
the report in the Navigator opens the report on screen. Until that
works you can't go forward.
I also assume that you have downloaded the latest issue of the dUFLP and
have saved its version of preview.wfm in your dUFLP folder. Unless you
do this you will need to build an AssocArray to hold parameters or the
report's query and you will need to overwrite the report's render()
method to deal with the AssocArray.
> However I am getting :
>
> Class does not exist repFormForm :: pushbutton4_onclick.
In your original message you show the event handler for pushbutton4's
onClick event handler as function PUSHBUTTON4_onClick1
Check, in the sourcecode editor, the constructor code for pushbutton4 in
repform.wfm. The event handler assigned to the onClick event must match
the actual function name. If the assignment is onClick =
class::PUSHBUTTON4_ONCLICK then you need to make sure that
PUSHBUTTON4_ONCLICK is the name of your function.
>
> This happens on any other pushbutton where the report is simple with
> no params to pass.
> I believe that the onclick events are Ok in themselves as per your
> suggestion using "Form.oPreview.open()"
>
> It appears that the onOpen event is causing this problem. >
> If I remove it together with 'onOpen = class :: FORM_ONOPEN' and just
> use " do...with preview.wfm" the report renders > ( Albeit ignoring " file does not exist" for smallfonts and file path
> for messanger and accompaning errors.)
>
> I am at a loss to find a solution to this having read preview usage
> etc.
You may have other code in the form's form_onOpen event handler
(function) but the only code needed in the function to be able to launch
preview.wfm to display your report is
set procedure to :duflp:preview.wfm //Makes preview available
form.oPreview = new previewForm()
//Creates an instance of the preview form and saves it in memory
form.oPreview.bModal = true
form.oPreview.bClose = false
//These can be set in the function used to launch a report but as
//one normally uses the same settings for all reports it makes sense
//to set them here if you have several reports.
set procedure to whatever.rep //Use the actual filename
form.oRep = new whateverReport()
//Use the actual classname for the report.
//Creates an instance of the report and saves it in memory.
//The instance in memory will have records available appropriate
//for the dummy dates used for the query's parameters.
As long as you have used the correct filenames for preview.wfm and your
report and the correct classnames when you create the instances of the
two classes there should be no errors when you open the form. If there
are errors when the form opens, look for typos.
Once you have instances of the preview form and your report safely
tucked away in user-defined properties of the form you can proceed to
launch them from a pushbutton's onClick event handler. Apart from code
to test that the user has actually supplied dates, the following code in
a pushbutton's onClick event handler is all you need. Start with this
code and once it works add the test and code to reset the entryfields later.
form.oRep.transfer1.params['fdat1'] = form.entryfield1.value
form.oRep.transfer1.params['tdat1'] = form.entryfield2.value
//Replace the dates in the report query's parameters
form.oRep.transfer1.requery()
//Requery the report's query to fetch appropriate records
//Any other property of the report can be altered here as well
//if required.
form.oPreview.viewer = form.oRep
//Pass the instance of the report to the instance of preview.wfm
//Older versions of preview don't have this facility and require
//added code in the report to deal with parameters passed using an
//AsssocArray. This way is much less work. :-)
form.oPreview.open()
Mervyn.
|
|