Microsoft KB Archive/157052

= How To Display Blank in Place of .NULL. in a Grid Column =

Article ID: 157052

Article Last Modified on 7/1/2004

-

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 6.0 Professional Edition

-



This article was previously published under Q157052



SUMMARY
This article describes how to display a blank in place of .NULL. in a Grid column in Visual FoxPro 3.0, and 3.0b.



MORE INFORMATION
By default, fields containing NULL values are displayed as .NULL. in a Grid in all versions of Visual FoxPro. To display a blank in place of .NULL. in a column of a grid in Visual FoxPro 3.0 and 3.0b, place an inline if (IIF) statement in the DynamicForeColor property of the subject column. The IIF sets the column's ForeColor to the same color as the Grid Column's BackColor when the field contains a value. In Visual FoxPro 5.0 a NULL value can be displayed as a blank in a Grid by issuing the following SET command, which makes setting the DynamicForeColor unnecessary: SET NULLDISPLAY TO '' Use the following steps to set the DynamicForeColor property of a column to white when a field contains a NULL value and to black when the value is not NULL. This article assumes that the Grid column's BackColor property is white (255,255,255) and that the ForeColor property is black (0,0,0). This article also assumes a working knowledge of creating forms, grids, and tables.

 Create a table called Test.dbf with a numeric field named nNulltest, which allows null values. Add some records to the table, storing .NULL. in the nNulltest field of some of the records. Create a form. Add the table Test.dbf, created above, to the DataEnvironment of the form. Create a Grid on the form by dragging Test.dbf onto the form. Change the Grid's ColumnCount property to 1.  Place the following in column 1's DynamicForeColor property: IIF(ISNULL(nNulltest),RGB(255,255,255),RGB(0,0,0)) A true condition sets DynamicForeColor to white; a false condition is set to black. </li> Run the form. Notice that a blank instead of .NULL. appears in the rows of the Grid pertaining to records with a NULL value in the nNulltest field. Should you get an error message starting with "Error loading file," you can correct the problem by deleting the = (equal sign) placed at the beginning of your IIF statement in the DynamicForeColor property.</li></ol>

Keywords: kbhowto KB157052

-

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

© Microsoft Corporation. All rights reserved.