>I need to create a report based off information in a file I call LOG. This is an accumlative file being that it has data (mostly amounts) that start with an initial starting balance record and progress.
>
>I need to have the user select the starting and ending dates for the report. The report needs to read all records PRIOR to the starting date to get a starting balance and only print records from the starting date through the ending date.
>
>The balances depend on the various records record type... some add to certain fields, some subtract, some just printout.
>
>The concept seems relatively straight forward except I only have written reports that list ALL the data in the file and doesn't do the selected printing, selected reading and mathematics based on a field type.
>
>How do you accomplish something like this with the report writer? Suggestions?
When I need to do a conditional add or subtract summation, I do something like:
Select some_id, sum(some_field * iif(some_condition, 1, -1)) as PrevBal from LogTable where LogDate < ? dStartDate into cursor crsTemp nofilter
In order to create an index on the cursor:
select crsTemp
use dbf() again in 0 alias crsPrevBal
use
select crsPrevBal
index on some_id tag some_id
select LogTable
set order to LogDate
set relation to some_id into crsPrevBal
seek dStartDate
report form MyReport rest to printer noconsole
The REST clause will start at the currently selected record and print until eof().
Mark McCasland
Midlothian, TX USA