Microsoft KB Archive/191316

= PRB: SET DATASESSION TO Fails From a Method of _Screen =

Article ID: 191316

Article Last Modified on 12/11/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q191316



SYMPTOMS
Attempting to set the data session of a form by calling the SET DATASESSION TO command from a method of _SCREEN fails.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Create a program that contains the following code: CLEAR ALL PUBLIC yy,Y,zz

* The target session we are trying to SET TO: Y = CREATEOBJECT("zform")

* A separate custom object, which can set to that session: zz = CREATEOBJECT("myobj")

* A form in another session, which can set to that session: yy = CREATEOBJECT("zform2")

* A member of screen, which will show the problem: _SCREEN.ADDOBJECT("z","myobj")

Y.SHOW yy.SHOW

RETURN

DEFINE CLASS myobj AS CUSTOM

PROCEDURE SetToActiveSession WAIT WINDOW TIMEOUT 1 ; "current ;           session: "+STR(SET("datasession")) SET DATASESSION TO ; (_SCREEN.ACTIVEFORM.DATASESSIONID) WAIT WINDOW "session we want: "+; ALLTR(STR(_SCREEN.ACTIVEFORM.DATASESSIONID))+ ; ", "+ CHR(13)+ ; "session we got: "+ ; ALLTR(STR(SET("DATASESSION"))) TIMEOUT 3 ENDPROC

ENDDEFINE

DEFINE CLASS zform AS FORM DATASESSION = 2 ENDDEFINE

DEFINE CLASS zform2 AS zform AUTOCENTER = .T.        ADD OBJECT z AS COMMANDBUTTON WITH ; CAPTION="Push Me" PROCEDURE z.CLICK WAIT WINDOW TIMEOUT 1 "current session: "+STR(SET("datasession")) SET DATASESSION TO (Y.DATASESSIONID) WAIT WINDOW "session we want: "+ ; ALLTR(STR(Y.DATASESSIONID))+ ; ", "+CHR(13)+ ; "session we got: "+ ; ALLTR(STR(SET("DATASESSION"))) TIMEOUT 1 ENDPROC ENDDEFINE  Run the program and press the command button. Notice the data session starts out with a value of three (3) and changes to a value of two (2). Change the data session from the Command window by typing the following command:

zz.SetToActiveSession

Notice the data session starts with a value of one (1) and successfully changes to two (2). Attempt to change the data session from the Command window using a method of the _SCREEN object by typing the following:

_Screen.z.SetToActiveSession

Calling the _SCREEN object does not allow you to change the data session to a value of two (2). It remains a value of one (1).

Additional query words: kbVFp500a kbVFp600 kbOOP

Keywords: kbprb KB191316

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.