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能显示找到记录,但光标却没有自动指向指到的记录,不知为何

解决方案 »

  1.   

    我另写的程式:
    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没设好还是哪不行?
      

  2.   

    locate('pn_no',trim(zdnbedit.text),[loCaseInsensitive,loPartialKey])变成locate('pn_no',trim(zdnbedit.text),[]) 看看
      

  3.   

    也不行,我开始就是写成locate('pn_no',trim(zdnbedit.text),[]),怪了,
      

  4.   

    DBGRID已连接好,可以看到数据。可以上下移动记录。但就是LOCATE不能定位数据,真是怪了!
      

  5.   

    zdnbedit.text这东西是DB类的还是TEDIT类的?
      

  6.   

    locate('pn_no',trim(zdnbedit.text),[loCaseInsensitive])
      

  7.   

    eg:procedure TForm1.Button3Click(Sender: TObject);
    begin
      ADOTable2.Active:=true;
      if ADOTable2.Locate('fdid','13',[]) then
      begin
         Edit3.Text:=  ADOTable2.FieldByName('fdname').AsString;
      end
    end;
      

  8.   

    Locate()返回值为True,表明确实找到了记录,但看不到光标同时移到那条记录?你是用DBGrid来显示记录的吧? 那还应该DBGrid.setfocue;
    也就是说,要让DBGrid获得焦点,这时你就能看到结果了。
      

  9.   

    只能說明DBGrid並不是與Datamdu.Tbcutpn連接的