You are basically SOL. There is no DataSessionID property for the report or the report's DE. The data session will appear in the Data window and show its number, but you really have no way of getting the ID. You could have the report open some dummy table, then you can loop through possible data session IDs looking for that table being open.
lnOldDSID = set('datasession')
lnOldError = on('error')
on error llBadDS = .t.
llBadDS = .f.
llFound = .f.
for lnI = 1 to 100
set datasession to lnI
if used('SomeTable')
llFound = .t.
exit
endif
if llBadDS
exit
endif
endfor
set datasession to (lnOldDSID)
on error &lcOldError
if llFound
lnRptDSID = lnI
else
lnRptDSID = .null.
endif
return lnRptDSID
>I have a VFP report using a private datasession that I execute as follows:
>
>public oFilters
>
>oFilters=NEWOBJECT('reportsfilter','appfilters')
>oFilters.rpt_closure_key()
>
>REPORT FORM CURDIR()+'report\&gcReportName'
>
>
>.rpt_closure_key() is the method that creates the cursor "proposal" used by the report.
>
>
>My question is, how do I tell the report the name of the cursor to use. I can't add it as a table in the data environment. In the report datasession init I tried adding:
>
> set datasession to 1
> select proprosal
>
>That works if nothing else is open, however, if I have a form open first then the report doesn't use datasession 1.
>
>Keith
Mark McCasland
Midlothian, TX USA