Mark,
This makes sense (sort of)... I assume I put this in the click of the button I call to run the report. And I assume that is where I collect the starting and ending date. If I understand this correctly, then because of the seek, that repositions the file and the report runs on from their. To make sure it doesn't read any data past the enddate, I would include that in the select, correct? Also, in the report, how would I use the fields? I would need to use them from the cursor, correct? Seeing how that is created programmatically, am I going to have a problem with the report writer not finding the fields?
Thanks
>>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().
Peter Brama
West Pointe Enterprises
VFP is getting easier but STILL alot to learn!!