Microsoft KB Archive/162256

= FIX: TextBox Value in Grid Column Using Numeric ControlSource =

Article ID: 162256

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q162256



SYMPTOMS
When you enter numeric data of a number greater than 10 into a text box within a grid on a FoxPro form, it is correctly entered into the table. However, if the Grid1.Column1.Text1 value is referenced, it appears as zero. This behavior only occurs in version 3.0b.



RESOLUTION
Set each Grid TextBox InputMask property as follows: Grid1.TextBox1.InputMask = 9999.99 Grid1.TextBox2.InputMask = 9999.99



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in FoxPro 5.0 for Windows.



Steps to Reproduce Problem
  Copy the following code to a test program and run it to create a Test.dbf that contains two sample records: ***** Table setup for TEST ***** CREATE TABLE 'test.dbf' ; (DISCOUNT N(10, 2) NOT NULL, ;        AMOUNT N(10, 2) NOT NULL, ;         OTHER N(10, 2) NOT NULL)

***** Add two records for testing ***** INSERT INTO test (DISCOUNT, AMOUNT, OTHER) ; VALUES (7.00, 4.00, 0.00) INSERT INTO test (DISCOUNT, AMOUNT, OTHER) ; VALUES (9.00, 15.00, 10.00)  Create a new form, and add the Test table to the data environment. Drag the Test table from the data environment to the form to create a grid.  Set the following grid properties: Grid1.ColumnCount = 2 Column1.ControlSource = test.discount Header1.Caption = "Discount" (without the quotes) Column2.ControlSource = test.amount Column2.Header1.Caption = "Amount" (without the quotes)  On the Form Controls toolbar, click Label and place three Label controls on the form to the right of the grid.  Set the following Caption properties on the three Labels (without the quotes): Label1.Caption = "Value" Label2.Caption = "IsZero?" Label3.Caption = "Field" </li> On the Form Controls toolbar, click TextBox and place three TextBoxes on the form, one to the right of each label.</li>  Set the following Name properties on the three TextBoxes: Text1.Name = txtNewValue Text2.Name = txtZero Text3.Name = txtNewField </li>  Enter the following code in the LostFocus event of the (Discount column) Grid1.Column1.Header1.Text1: THISFORM.txtNewvalue.Value = THIS.Value IF THIS.Value = 0 THISFORM.txtZero.Value = "Yes" ELSE THISFORM.txtZero.Value = "No" ENDIF THISFORM.txtNewField.Value = test.discount </li>  Enter the following code in the LostFocus event of the (Amount column) Grid1.Column2.Header1.Text1: THISFORM.txtNewvalue.Value = THIS.Value IF THIS.Value = 0 THISFORM.txtZero.Value = "Yes" ELSE THISFORM.txtZero.Value = "No" ENDIF THISFORM.txtNewField.Value = test.amount </li> Run the form.</li> Enter a new number in the first record of the form's Discount column and notice that if the number entered is less than 10 that the number is displayed correctly in the TextBox beside "Value" and the answer displayed in the TextBox beside "IsZero?" is correct.</li> Repeat step 12 for the first record of the Amount column.</li> Enter a new number that is greater than 10 in the first record of the Discount column. Notice that the number displayed in the "Value" TextBox is "0" and the answer displayed in the "IsZero?" TextBox is incorrect.</li> Repeat step 14 for the first record of the Amount column.</li></ol>

<div class="references_section">