procedure TzdinfoForm.zdnbEditExit(Sender: TObject);
begin
//zdnbedit.text:=trim(zdnbedit.text);
with Datamdu.Tbcutpn do
begin
//first;
If locate('pn_no',trim(zdnbedit.text),[loCaseInsensitive,loPartialKey])
then
begin
showmessage('find the reco');
edit;
end
else
append
end;
如上这些代码,现在SHOWMESSAGE能显示找到记录,但光标却没有自动指向指到的记录,不知为何
begin
//zdnbedit.text:=trim(zdnbedit.text);
with Datamdu.Tbcutpn do
begin
//first;
If locate('pn_no',trim(zdnbedit.text),[loCaseInsensitive,loPartialKey])
then
begin
showmessage('find the reco');
edit;
end
else
append
end;
如上这些代码,现在SHOWMESSAGE能显示找到记录,但光标却没有自动指向指到的记录,不知为何
procedure TForm1.Edit1Exit(Sender: TObject);
begin
with table1 do
begin
if locate('pn_no',edit1.text,[])
then
begin
showmessage('find the record');
edit;
end
else
begin
showmessage('cannot find the record');
append;
end;
end;end;
这个就行,怪了,困惑我几天了,LOCATE能找到记录,但指针就是没定位,哪位能说下,是DATASOURCE没设好还是哪不行?
begin
ADOTable2.Active:=true;
if ADOTable2.Locate('fdid','13',[]) then
begin
Edit3.Text:= ADOTable2.FieldByName('fdname').AsString;
end
end;
也就是说,要让DBGrid获得焦点,这时你就能看到结果了。