>I am using Cursor for my reports. For example Select * from Mytable into cursor XYZ and after that I am using reports to preview it.
>
>The problem.
>
>The first time when I generate the reoprt, It runs fine but the second time it gives error as file is in use (XYZ cursor).
>
>Now, first where should i write USE in (XYZ) and second My progeram requires that there may be N number of Cursors with different name but the report generated will be the same. So I am looking for a command that could tell me which is the active table and than after I will execute the command USE IN ...
>
>In short,
>
>I need to know (1) How to determine the active table/cursor Name
>(2) Where should i write use in .. somewhere in the report ?
1.Make sure that Report's Data Environment is empty. Otherwise report will work with the table/cursor name from data environment, not from the dynamically created cursor.
2. Before calling the report make sure that there is no open table/cursor having the same alias name as cursor XYZ
use in (select("XYZ"))
You may also need to check for a table XYZ.dbf that is in use, but with different alias. I do not know details of your application, but releasing a particular table may cause problems down the road. If you want to close the table you can use something like:
if aused(aa)>0
for ia=1 to alen(aa)
if dbf(aa[ia])="XYZ"
use in (aa[ia])
endif
endfor
endif
3. Make sure that you select proper table/cursor before calling the report, and release it after report is done.
select your_cursor
report form .....
use
Best Wishes