>I must be making a mistake in assuming how * I * think things should work here - I need help!
>
>I have a StartUp form that runs in the Default DataSession; it opens all the files that will be used in reports, etc. in it's Data environment. Users can launch other forms from this StartUp form or from the menu.
>
>Every other non-modal form in the system uses Private DataSessions.
>
>My reports are called from the REPORT menu, and all call ReportIt.Prg, w/a parameter that specifies what report should be run.
>
Jill, the child form using Default Datasessions inherits the same datasession as the parent form - if the parent form is using a private datasession, the child report using default datasession will share the parent's private datasession as a result.
I haven't tried this approach (I run VFP reports in private datasessions in almost all cases to prevent side-effects from occurring), but you might try altering ReportIt to launch a hidden form using a default data session. Save the actual datasession assigned in a member property, and switch the datasession of the form to 1 (Default) in the Init of the form. If a report then uses the default datasession, it'll inherit the datasession from the ReportIt form. During the Form's Release method, change the dastasession back to the one saved in the member property so that you don't end up leaving disconnected datasessions floating about.
Is there some reason to run the report in the default datasession? Using private datasessions has been (for me at least) far less prone to accidental side-effects from having tables autoclosed because of carelessness on my part, but that's likely a matter of the coding style I use to build VFP reports.
>I want all my reports to run in THE Default DataSession (1), no matter what other forms are open. If other forms are open, I thought, that to allow reports to run in DS 1, what I'd have to do is:
>
>- at the beginning of ReportIt, do the following:
>
>nSaveDataSessionID = SET( "DataSession" ) && save the current data session
>Set DataSession to 1 && the default data session, used by the StartUP form
>
>- at the end of ReportIt, to restore to the previous DS:
>
>Set DataSession to ( nSaveDataSessionID ) && restore current data session before RETURNing
>
>
>This doesn't work for me...looking at the debugger, and using a WAIT WINDOW to display values, the DS does not get changed. I tried, at the beginning of ReportIT:
>
>nSaveDataSessionID = SET( "DataSession" ) && save the current data session
>Set DataSession to 1 && the default data session, used by the StartUP form
>nt = SET( "DataSession" )
>wait window alltrim( str( nt ) ) + " is the datasession"
>
>The results of the wait window display is 2! I feel like I'm missing something obvious, can anyone help point it out?
>
>TIA J