| Subject |
Re: Preview.wfm and report printing |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Wed, 1 Nov 2023 15:20:20 +0200 |
| Newsgroups |
dbase.getting-started |
On 2023/10/31 18:32, trevor wrote:
> Mervyn,
>
> Thanks for the forms.
> I know this is basic but as said long time no dbase.
>
> I'm getting "database alias expected" line 15.
> I've orders.dbf in database alias dbaseSamples and tried with the
> report in an other directory & also same directory.
>
> As an aside on rummaging through Ken's dbase report book, I noticed
> after examples of coding in report render using assoc array he gives an
> example similar to your suggestion, but states you need dBase 2.5.
> Could this be a requirement as well as latest preview (which is not
> mentioned).
Mm, it looks as if the reportviewer object only had it's ref property
surfaced in dBASE Plus 2.5. This means you can't use the latest version
of preview.wfm. :-(
If you need to change more than just the dates then Ken's solution in
his Reports book using an AssocArray is the way to go. I haven't dug
into preview.wfm too deeply but it looks as if it only deals with a
filter as it stands. If you needed to set, say, text properties it
should be possible to add a loop to handle other entries in the AssocArray.
If you only need to changes the records based on dates then Michael's
suggestion of creating a temporary table is probably the easiest
solution. This needs no changes to the report code that is streamed out
by the designer. You do, however, need to use the temporary table in
the report's query.
Instead of using XDML as Michael did I would use localSQL. Dates in a
SQL SELECT statement must be supplied as delimited literal values.
cSafety = set('safety')
set safety off // Avoid "table exist" message
cmd = "select * from transfers where transfer between '"
cmd += dtoc(form.entryfield1.value)+"' and '"
cmd += dtoc(form.entryfield2.value)+"' "
cmd += "order by fld1,fld2 "
cmd += "save to transfers_temp"
//?cmd //Uncomment to view SELECT statement
&cmd
use //To close workarea created by the SELECT
set safety to &cSafety
do preview.wfm with 'transfers.rep'
The code above is designed to deal with a specific report but it can be
easily adapted to pass in reportname, tablename and fieldnames to make
it more flexible.
localSQL will only accept American (mm/dd/yyyy) or German (dd.mm.yyyy)
so if your date format is not one of these you will need a bit more work.
function sql_date(dDate)
cDate_form = set('date')
set date to american
cLit_date = ctod(ddate)
set date to &cDate_form
return cLit_date
....
cmd += class::sqldate(form.entryfield1.value)+"' and '"
cmd += class::(form.entryfield2.value)+"' "
....
Mervyn.
|
|