Subject Re: Preview.wfm and report printing
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Tue, 24 Oct 2023 15:56:54 +0530
Newsgroups dbase.getting-started

Good Evening Trevor,

> Using dBase Plus 2.21, Preview.wfm 2.22 ( early 2000's)
>
> Long time away from coding as evidence of version age.
>
> I have a form with several button calling various reports ,one of which
> I would like to choose report date ranges.
> Before I call preview it uses two entryfields " from date" and " to
> date". These values are then stored as variables.
>
> function PUSHBUTTON4_onClick1
>
>            if form.entryfield1.value = {  -  -    } or
> form.entryfield2.value = {  -  -    }


>
> Would it be possible in the first example to pass varriable in the sql
> "where clause" to 2nd calling of rep on print request  or
>
>   in 2nd : ascribe setrange()  rowset to table of report . Also  I'm not
> clear what is required further in report  Render() method.

I am using 12.3 with ADO so my syntax will be a little different.

set procedure to cash_book.rep
if form.rowset.count()>0
        local r
         r = new cash_bookreport()
         r.cashdatamodule1.cash.params["fr_date"].value=
dtos(form.from_date.date)
          r.cashdatamodule1.cash.params["to_date"].value=
dtos(form.to_date.date)
          r.cashdatamodule1.cash.requery()
          r.PAGETEMPLATE1.REPORT_TITLE.text = "Cash Book of a/c "+
alltrim(form.cash_ac.value)+" from "+dtoc(form.from_date.date)+" to "
+dtoc(form.to_date.date)
          set procedure to preview.wfm additive
          r.output = 0
          fPreview = new PreviewForm()
          fPreview.windowState = 2        // Maximized
          fPreview.bModal = true
          fPreview.bClose = false
          fPreview.bShowHTML = false // default
          fPreview.viewer.ref := r // <-- new
          fPreview.open()
          fpreview.release()
          r.release()
          close procedure preview.wfm
       endif

I am using the above code successfully.

For printing I just have to click the print button on the preview form.
For printing without preview there is a separate button.

I am not facing any issues.

Regards
Akshat