>>As far as I know, if you run your function from a form (say, command button), this function already operates within Private Form's DS, so you don't need to do anything special.
>
>Yes, this is my experience, too.
>
>>Otherwise you can pass Form's DS as a parameter. My colleagues use SET DATASESSION to lnPassedDS lots of times in a code without problems...
>
>Thanks; the "without problems" is the part that interested me.
>
>Instead of a parameter, I plan to get .DataSessionId, from _vfp.ActiveForm. You see, the reason I want an outside function in the first place is because I want to have a generic function called from a menu. So, I can't pass a parameter from the form.
>
>Hilmar.
Yes, I think it will work. Just be careful, don't forget to save it prior to changing and restore at the end, also don't overwrite currently opened aliases (e.g. create cursor command should be preceeded with select 0, we had this problem with one of our applications, which didn't have this command and so screwed up the currently running form's DS).
If it's not broken, fix it until it is.
My Blog