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

Last reviewed: February 6, 1998
Article ID: Q180615
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a
  • Microsoft Visual FoxPro for Macintosh, version 3.0b

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 is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. 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
    
    

  2. Run the program and enter text into the first text box.

  3. Tab to the next text box.

    The text in the control changes to .NULL.

Keywords          : FxtoolFormdes VFoxMac vfoxwin vfp50abug vfp50bug kbcode
Version           : MACINTOSH:3.0b; WINDOWS:3.0,3.0b,5.0,5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.