Microsoft KB Archive/180615

= BUG: Text Box Value Does Not Change If ControlSource Is .NULL. =

Article ID: 180615

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q180615



SYMPTOMS
When the ControlSource property of a text box control is set to the custom property of a form and the custom property is .NULL., the text in the control cannot be changed. If the text in the control is edited, the text changes to .NULL. when the control loses focus.



RESOLUTION
Change the class definition in the code below to add the KeyPress method as follows: DEFINE CLASS NewTextBox AS textbox PROCEDURE KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl *-- Once the text has changed, set the custom *-- property of the form to the text box. ThisForm.custom_prop = This.Value ENDPROC ENDDEFINE



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
  Create a program using the code below that creates a form with a custom property and two text boxes. The ControlSource of the first text box is set to the form's custom property. frmMain = CREATEOBJECT("frmBase") frmMain.Show READ EVENTS

DEFINE CLASS frmBase AS Form

*-- Set the property to a character type. custom_prop = ""

PROCEDURE Init ThisForm.custom_prop = .NULL. ENDPROC

PROCEDURE Unload CLEAR EVENTS ENDPROC

*-- Create the text box that gives the problem. ADD OBJECT text AS NewTextBox WITH ; Left = 100, ; Top = 0, ; Width = 250, ; Name = "txtText",; NullDisplay = ".NULL.",; ControlSource = "thisform.custom_prop"

*-- Create another text box to give you something to tab into. ADD OBJECT text2 AS TextBox WITH ; Left = 100, ; Top = 50, ; Width = 250, ; Name = "txtText2" ENDDEFINE

DEFINE CLASS NewTextBox AS textbox ENDDEFINE  Run the program and enter text into the first text box. Tab to the next text box.

The text in the control changes to .NULL.

Keywords: kbbug kbprb kbcode KB180615

-

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

© Microsoft Corporation. All rights reserved.