Hi
I've seen that calling a method of an object automatically switch datasession to datasession in which object was created (Default?).
You can add a property to your form class to you store reference to oToolBox at Init(). Then all will take place in form's datasession.
You can call thisform.oToolBox.oGlobalStr.GetLogSeekStr(...)
After I've done this, I didn't need to switch between datasessions any more.
>Hello everybody
>
>Before i start, i know u can switch DS with 'set datasession to' <s>, thats my problem, it's not working as expected.
>
>here is the setup i have:
>
>at app initialization i create an object called 'oToolBox'. this is a class/function container controling the creation and destruction of support functions. at that time this class is empty.
>
>one of my forms started later through menu, has a private datasession. this form now calls a function controlled through the 'oToolBox' like this:
oToolBox.oGlobalStr.GetLogSeekStr(...)
. oToolBox now automaticly creates/attaches an instance of 'oGlobalStr' and executes the method called.
>
>this all works fine, but, since this was called from a form with a private ds, the command
TblName = dbf(AliasName)
does not work. it errors "Alias Not Found".
>
>in the debugger this command executes correctly.
>
>so i added at the begining of my method the following:
>if Type("_screen.ActiveForm.DatasessionId") = "N"
> CurrentDS = set("datasession")
> CallingFormDS = _screen.ActiveForm.DatasessionId
> if CallingFormDS <> CurrentDS
> ResetDS = .t.
> set datasession to &CallingFormDS
> endif
>endif
>which also executes all the way through, however the above mentioned command is still throwing the same error. the form in question is active, the table is open with that alias, in the debugger the dbf() shows the correct result - i have no clue, can u not change ds 'on the fly' like this? are there 'easy' alternatives, do i do something wrong?
>
>thanks for all your help in advance!