PRB: ControlSource Variables not Visible until Text Box SelectedID: Q196086
|
If you base the ControlSource of a text box on a private or local memory variable and is the text box is populated before the form runs, then the variable is not visible to the methods or events of the form and its components until you select the text box by either clicking the text box or tabbing to the text box.
When the form is first instantiated, the memvars are still in scope. After the form has fully instantiated, the .prg file continues and ends, releasing the memvars. You can still see the values in the text boxes because the values were read before the memvars went out of scope. When you click the text box, it tries to refresh from the Controlsource. However, the Controlsource memvar does not exist, so the text box creates the memvar, and stores the current text box value in that memvar.
Following are two workarounds:
CLEAR ALL
USE MyTbl
SELECT MyTbl
SCATTER MEMVAR
DO FORM MyFrm
READ EVENTS
-or-
This behavior is by design.
CREATE TABLE MyTbl (Fld1 C(2), Fld2 n(2), Fld3 n(2), Fld4 n(2))
INSERT INTO MyTbl Values ("aa",1,1,1)
INSERT INTO MyTbl Values ("bb",2,2,2)
M.Fld4 = M.Fld2 + M.Fld3
CLEAR ALL
USE MyTbl
SELECT MyTbl
SCATTER MEMVAR
DO FORM MyFrm
Variable Fld2 is not found.
Variable Fld3 is not found.
Additional query words:
Keywords : kbContainer kbCtrl kbVFp300b kbVFp500 kbVFp500a kbVFp600
Version : WINDOWS:3.0,3.0b,5.0,5.0a,6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: August 8, 1999