procedure TForm_platepo.edt_poChange(Sender: TObject);
begin
if length(trim(edt_po.Text))=8 then
begin
datamodule1.qry_platepo.active:=true;
if datamodule1.qry_platepo.Locate('po',trim(edt_po.Text),[])=true then
begin
application.messagebox('此PO已开过单,请查正!!', '提示', MB_OK + mb_iconwarning);
abort;
end;
end;
end;
我的po不是主键,但也没理由找不着啊,我执行结果就是没反应,我数据库有相应的记录,但就是没提醒过我,此PO已开过单,请查正!!为什么
begin
if length(trim(edt_po.Text))=8 then
begin
datamodule1.qry_platepo.active:=true;
if datamodule1.qry_platepo.Locate('po',trim(edt_po.Text),[])=true then
begin
application.messagebox('此PO已开过单,请查正!!', '提示', MB_OK + mb_iconwarning);
abort;
end;
end;
end;
我的po不是主键,但也没理由找不着啊,我执行结果就是没反应,我数据库有相应的记录,但就是没提醒过我,此PO已开过单,请查正!!为什么
试着把=true去掉试。这跟主键没什么关系的
DataModule1.qry_platepo.sql.add('select * from 表名 where 字段名='''+edt_po.text+''''
DataModule1.qry_platepo.open;if datamodule1.qry_platepo.RecordCount=0 then
showMessage('没找到');这样还快一些。