I assume you have checked with a trace that Pump is ever true?

I would recommend checking for eof before trying to assign to the db
field.

 

      PSQLQuery2.Open;

      If not PSQLQuery.eof then

      begin

        Pump:= PSQLQuery2.FieldByName('pump1').AsBoolean ;

        DBCheckbox6.Enabled := Pump ;
      end;



Or

      PSQLQuery2.Open;

      If not PSQLQuery.eof then

        DBCheckbox6.Enabled := PSQLQuery2.FieldByName('pump1').AsBoolean
;

 

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
On Behalf Of Bob Pawley
Sent: Tuesday, 24 November 2009 8:01 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] TDBCheckbox

 

Hi

 

I have two tdbcheckboxes.

 

I want one checkbox to be disabled unless the other checkbox is checked.

 

The following does compile but DBCheckbox6 isn't enebled when the sql
condition is true.

 

Could someone suggest what it is I am doing wrong??

 

Bob

 

begin
  
       DBCheckbox6.Enabled := False;


          begin
        
            PSQLQuery2.Close;
      PSQLQuery2.SQL.Clear;
      PSQLQuery2.SQL.Add ('select (p_id.processes.pump1)');
      PSQLQuery2.SQL.Add ('from p_id.processes');
      PSQLQuery2.SQL.Add ('where p_id.processes.fluid_id = :Fluidid');
      PSQLQuery2.ParamByName('Fluidid').AsString := DBEdit2.Text;
      PSQLQuery2.Prepare;
      PSQLQuery2.Open;
      PSQLQuery2.First ;
      Pump:= PSQLQuery2.FieldByName('pump1').AsBoolean ;

 

          If
             Pump = True
        then
         DBCheckbox6.Enabled := True;
          end;
end;

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to