Vrtnar
asked on
ADOTable problem
Here:
procedure TForm2.ADOTable1AfterOpen(
var AutoIncCount : Integer;
begin
ADOTable1.Sort := 'ID DESC' ;
AutoIncCount := ADOTable1.Fieldbyname('Mem
cxTextEdit1.Text := inttostr(AutoIncCount + 1) ;
cxTextEdit2.SetFocus;
end;
procedure TForm2.ADOTable1AfterScrol
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record
StatusBar1.Panels[1].Text:
end;
Problem is this:
How do I prevent the program from crashing down if the adotable1 is empty
at runtime??
ASKER
It does not work right...
The only way it seems to work is :
procedure TForm2.ADOTable1AfterScrol l(DataSet: TDataSet);
begin
if not ADOTable1.Bof then
begin ....
Why is it when I delete last record from table
StatusBar1.Panels[1].Text: = ' Current record :' +inttostr(ADOTable1.RecNo) ;
statusbar displays -1 ???
The only way it seems to work is :
procedure TForm2.ADOTable1AfterScrol
begin
if not ADOTable1.Bof then
begin ....
Why is it when I delete last record from table
StatusBar1.Panels[1].Text:
statusbar displays -1 ???
Vrtnar
use ADOTable1.RecordCount in the events i mean :
procedure TForm2.ADOTable1AfterOpen( DataSet: TDataSet);
var AutoIncCount : Integer;
begin
if ADOTable1.RecordCount>0 then
begin
ADOTable1.Sort := 'ID DESC' ;
AutoIncCount := ADOTable1.Fieldbyname('Mem ber_ID').A sinteger;
cxTextEdit1.Text := inttostr(AutoIncCount + 1) ;
cxTextEdit2.SetFocus;
end;
end;
procedure TForm2.ADOTable1AfterScrol l(DataSet: TDataSet);
begin
if AdoTable1.RecordCount then
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem ber_ID').A sString ;
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record count);
StatusBar1.Panels[1].Text: = ' Current record :' +inttostr(ADOTable1.RecNo) ;
end;
end;
use ADOTable1.RecordCount in the events i mean :
procedure TForm2.ADOTable1AfterOpen(
var AutoIncCount : Integer;
begin
if ADOTable1.RecordCount>0 then
begin
ADOTable1.Sort := 'ID DESC' ;
AutoIncCount := ADOTable1.Fieldbyname('Mem
cxTextEdit1.Text := inttostr(AutoIncCount + 1) ;
cxTextEdit2.SetFocus;
end;
end;
procedure TForm2.ADOTable1AfterScrol
begin
if AdoTable1.RecordCount then
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record
StatusBar1.Panels[1].Text:
end;
end;
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I think the reason is that because its an empty recordset then there is no current record number so it returns a default '-1', use the code below
procedure TForm2.ADOTable1AfterScrol l(DataSet: TDataSet);
begin
if not (ADOTable1.Bof) and (ADOTable1.Eof) then
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem ber_ID').A sString ;
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record count);
StatusBar1.Panels[1].Text: = ' Current record :' +inttostr(ADOTable1.RecNo) ;
end
else
begin
StatusBar1.Panels[0].Text := ' All records : 0';
StatusBar1.Panels[1].Text: = '';
end;
end;
procedure TForm2.ADOTable1AfterScrol
begin
if not (ADOTable1.Bof) and (ADOTable1.Eof) then
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record
StatusBar1.Panels[1].Text:
end
else
begin
StatusBar1.Panels[0].Text := ' All records : 0';
StatusBar1.Panels[1].Text:
end;
end;
var AutoIncCount : Integer;
begin
if not ADOTable1.Eof then
begin
ADOTable1.Sort := 'ID DESC' ;
AutoIncCount := ADOTable1.Fieldbyname('Mem
cxTextEdit1.Text := inttostr(AutoIncCount + 1) ;
cxTextEdit2.SetFocus;
end;
end;
procedure TForm2.ADOTable1AfterScrol
begin
if not (ADOTable1.Bof) and (ADOTable1.Eof) then
begin
wwdblookupcombo1.text := ADOTable1.FieldByName('Mem
StatusBar1.Panels[0].Text := ' All records :' +IntToStr(ADOTable1.record
StatusBar1.Panels[1].Text:
end;
end;