Vlad,
Thanks for the procedure. I'm able to use this logic in my procedure.
I may have some questions when I get to the part on selecting a "Range" of records though.
Thanks for the help.
Elgin
>Hi, Elgin!
>
> Try to use 'SET FILTER' command. So you will need only 'SCAN' without any conditions in you stored procedure. This command is also optimizable when scanning records despite '&', that is not tru for many other commands. Following is sample how procedure call will look like in the form which used to select options for report:
>
>
>local lcFilter
>
>lcFilter = ''
>do case
> case thisform.opgRecords = 1
>
> lcFilter = ''
> case thisform.opgRecords = 2
> lcFilter = 'CustID >= ' + allt(str(thisform.nCustIDRangeFrom)) + ;
> ' AND CustID <= ' + allt(str(thisform.nCustIDRangeTo))
> case thisform.opgRecords = 2
> lcFilter = 'CustID = ' + allt(str(thisform.nCustID))
>endcase
>IF ...
> lcFilter = lcFilter + iif(empty(lcFilter), '', ' AND ') + ;
> 'Upsino = [' + thisform.txtUpsino.Value + ']'
>ENDIF
>
>
>SELECT Nameplatv
>SET FILTER TO &lcFilter
>
>
>= PrepareReportCursor()
>
>
>SET FILTER TO
>
>
>
>>SCAN FOR Custid = gcCustid
>> Alot of Code..
>>ENDSCAN
>
>
>
>
>>I have a stored procedure that is used to create a report cursor. In this procedure is a SCAN FOR.... END SCAN that has alot of code in between for selecting data from my 5 child tables that I do not want to repeat if possible. However, I would like to give the user a few options for selecting the Parent records that will be included in the report.
>>
>>The statment currently looks like this for running the report for the currently selected Parent record:
>>
>>SELECT Namplatv
>>SCAN FOR Custid = gcCustid AND Upsino = gcUpsino
>>
>> Alot of Code for Building reportcursor.
>>
>>ENDSCAN
>>
>>I would like to give them the option to select All records for the current CUSTID like:
>>
>>SELECT Nameplatv
>>SCAN FOR Custid = gcCustid
>> Alot of Code..
>>ENDSCAN
>>
>>Or even a Range of records specified. This Stored procedure is launched from a button on a form called "ReportSelect" that I use to set which of two report forms to be used.
>>
>>I don't know how to change my "SCAN FOR" criteria according to what they select. I've tried using variables in place of the criteria and as expected did not work.
>>
>>Not sure if I'm approaching this correctly. My main goal is to not have to repeat all that code within the SCAN command.
>>
>>Thanks a million.