How do I test for NULL values in reports?
The data we get from the Assessor now has NULL valuesin some fields and my labels ave broken. How do I test for NULL values, and if it is NULL, then leave bank, else use the field value?
0
-
Hi Mike. I've done that by adding a script to the Script tab. The string/numeric null/empty logic is a little convoluted, but basically it searches each value for a null, and if so, it replaces it with a 0. This won't work if your fields are resolving coded domains (using the .name() method). ANyway, hopefully enough to get you going.
Chris
public void ActiveReport_DataInitialize()
{
int numRows = (rpt.DataSource as DataSet).Tables[0].Rows.Count;
for (int ii = 0; ii < numRows;ii++)
{
if ( string.IsNullOrEmpty((rpt.DataSource as DataSet).Tables[0].Rows[ii]["UTILITIES_Water_Hydrants.HYG_INLT_SZ"].ToString()) )
{
(rpt.DataSource as DataSet).Tables[0].Rows[ii]["UTILITIES_Water_Hydrants.HYG_INLT_SZ"]=0;
}
}
rpt.DataSource = ((DataSet)rpt.DataSource).Tables[0].Select(null, "UTILITIES_Water_Hydrants.HYG_NUMBER ASC");
}0
Please sign in to leave a comment.
Comments
1 comment