Subject Re: Preview.wfm and report printing
From Michael Italiano <michael@abstractservices.com.au>
Date Wed, 25 Oct 2023 09:03:24 -0400
Newsgroups dbase.getting-started

Hi Trevor,

I have used 2 methods to get around passing data from a main file to a report.

1. I create a second table with the date range result to be used in the report. eg: a= "tablea.dbf, b="temptable.dbf"

Use &a
COPY TO &b for (tdate => rp_date1 .AND. tdate <= rp_date2)

Then use table b for your report

2. Create public variables for your date range and set them in your main file. Also create a public variable for your sql statement. Assign your sql statement in your main file with your variables as your date range selected then in your report replace your sql statement with the string created in your main file. You can only do this via the text editor otherwise the sql statement gets over written.

I dont think it matters which version Dbase you use, using these two methods.

Hope this helps.

Regards,

Michael.

trevor  Wrote:

>
>
> Hi
> 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 = {  -  -    }
>                msgbox ("Give Dates")
>                   else
>                fdate = form.entryfield1.value
>                tdate = form.entryfield2.value                
>
>            do preview.wfm with "printrans.rep"          
>                
>                 form.entryfield1.value = {  -  -    }  // return form
> with blank dates for next choice
>                 form.entryfield2.value = {  -  -    }  
>                 endif
>                      return
>              
>  In thereport form I use :   sql select * from  transfers.dbf where
> transfer => :fdat1 and tranfers <= :tdate1
> passing after RequestLive  = false
> params[fdat1]= fdate
> params[tdat1]= tdate
> Active = true
>
> This works fine showing correct results in preview form, but fails on
> pressing "Print"; variable unknown .Because,I realise unfortunately,
> the print button calls the report again but the variables are no longer
> available.  I then tried a simple select only, no "where" condition and
> using the example from Preview.zip. Index on transfer, using
> assocarray() and setrange() as a single parameter but it failed I
> assume because setrange() requires a rowset which is not present.
>
>  if form.entryfield1.value = {  -  -    } or form.entryfield2.value = {
> -  -    }
>                msgbox ("Give Dates")
>                   else
>                fdate = form.entryfield1.value
>                tdate = form.entryfield2.value                
>           aparams = class::paramSetup()
>               do preview.wfm with "printrans.rep",aParams
>                 endif
>                      return
>
>  function ParamSetup()
>              aparams = new assocarray()          
>            aparams["dates1"]= setrange(fdate,tdate) // unable to set
> address of rowset?
>               return aParams
>
> 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.
>
> Thanks,  Trevor
>  
>
>
>
>  
>