title: Using Delphi OnDrawColumnCell how can I ensure record value exists prior to applying conditional format
body: <p>I am using Delphi 2010 with a dbgrid bound via ADO to a table in an Access mdb Database.</p>
  
  <p>This table is filtered based on clicks in a radio group box.  </p>
  
  <p>The following code colour codes the rows based on the data in the table, but fails with an error dialogue box stating</p>
  
  <pre><code>       "" is not a valid integer value
  </code></pre>
  
  <p>if the filter returns a null dataset.  I thought I had allowed for not invoking colour setting if no records returned but it appears not to work ; see code below</p>
  
  <pre><code>procedure TMainForm.DBGridAbsenceDrawColumnCell(Sender: TObject;
    const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
  begin
       //Need to add code to detect if record exists
       with DBGridAbsence.Canvas do
       begin
             RecordCountLabel.Caption.Text :=  'Absence Records: ' + IntToStr(ADOTblAbsence.RecordCount);
             font.color:=clBlack;
             brush.color:=clMoneyGreen;
             If ( ADOTblAbsence.State &lt;&gt; dsInsert ) and ( ADOTblAbsence.RecordCount &gt; 0 ) then
             begin
                  Font.Color := StringToColor(ADOTblAbsenceForeground.AsString);
                  Brush.Color:= StringToColor(ADOTblAbsenceBackground.asstring);
             end;
  
            DBGridAbsence.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      end;
  end;
  </code></pre>
  
  <p>Any and all help gratefully recieved.  Note I have also tried conditionals such as </p>
  
  <pre><code>if Trim(ADOTblAbsenceForeground.AsString) &lt;&gt; ''
  </code></pre>
  
  <p>but this does not appear to work either.</p>