我摘了一程序。
procedure Tslfrom.Edit11KeyPress(Sender: TObject; var Key: Char);
VAR
KV,kv1,kv2,kv3:string;
begin
if key=#13 then
begin
key:=#0;
with damo.pQuery do
begin
CLOSE;
sql.Clear ;
sql.Add('select * from data1');
prepare;
open;
last;
if damo.pQuery.RecordCount<>0
then
BEGIN
kv:=damo.pQuery.fieldbyname('ll').value ;
kv1:=copy(kv,1,8);
kv2:=copy(kv,9,3);
kv3:=copy((inttostr(year)+MM+DD),1,8);
if kv1=kv3 then
begin
if strtoint(kv2)<9 then kv2:='00'+ inttostr(strtoint(kv2)+1)
else if strtoint(kv2)<99 then kv2:='0'+inttostr(strtoint(kv2)+1);
kv:=kv1+kv2;
end else
kv:=inttostr(year)+MM+DD+'001'
END
else kv:=inttostr(year)+MM+DD+'001';
end;
label13.Caption:=kv;