filter_ADO:=Merchandise_info_.adoquery1;(这是正确的)////edit1.text值为Merchandise_info_
所以
var
ss:string;
begin
     ss:=edit1.Text;
     filter_ADO:=ss.adoquery1;(就错了)怎么改

解决方案 »

  1.   

    filter_ADO:='ss'+'.adoquery1';这样也不行呀
      

  2.   

     filter_ADO:=ss.adoquery1;(就错了)怎么改
    你想实现什么?你怎么可以把adoquery1数据集放在ss字符串后面呢?
    要打基础
      

  3.   

    实际情况是这样的,我对Merchandise_info_的利用adoquery属性做了一个万能查询
    Merchandise_info_.pas是主文件,PublicQuery.pas是个万能查询文件,现在针对Merchandise_info_.pas的万能查询成功了
    我现在想针对每个单元都做万能查询,所以我想得到哪个单元要做万能查询,当然不是Merchandise_info_.pas了,所以我想得到想做查询的单元名
    所以查询时
    begin
      inherited;
      With TPublicQuery.create(self) do
    begin
    edit1.Text:=self.name;
    showmodal;
    free;
    end;
    end;
    这样在PublicQuery.pas 的edit1.text得到想要做查询的单元名,所以我想把edit1.text替换
    filter_ADO:=Merchandise_info_.adoquery1里面的Merchandise_info_单元名
      

  4.   

    刚接触不久,所以不太了解
      Temp:=GetComponent(Merchandise_info_,GetLookADOName(Cells[1,row]),TADOQuery);//获取lookup数据原控件使用权
    还有这里的Merchandise_info_也要用edit1.text替换掉,但我不太懂
      

  5.   

    定义个一string的ss,就敢在后面加ss.adoquery1?
    不错才怪.
      

  6.   

    filter_ADO:='ss'+'.adoquery1';这样也不行呀
      

  7.   

    把所有的数据集放在一个datamodule中,就不需要引用那么多单元了,而且也不必要动态取了。
    否则你的这个"万能查询"不就不万能了吗。
      

  8.   

    把所有的数据集放在一个datamodule中,就不需要引用那么多单元了,而且也不必要动态取了。 
    否则你的这个"万能查询"不就不万能了吗。这个想法倒是对的,但是这样要改的东西太多了!
    办法总是有的  比如
    begin 
      inherited; 
      With TPublicQuery.create(self) do 
    begin 
    edit1.Text:=self.name; 
    filter_ADO:=self.adoquery1
    showmodal; 
    free; 
    end; 
    end; 
     在这里添加filter_ADO:=self.adoquery1就可以实现了呀,可是Temp:=GetComponent(Merchandise_info_,GetLookADOName(Cells[1,row]),TADOQuery);//获取lookup数据原控件使用权 
    可是这句不知道怎么写了
      

  9.   

    begin 
      inherited; 
      With TPublicQuery.create(self) do 
    begin 
    edit1.Text:=self.name; 
    filter_ADO:=adoquery1 
    showmodal; 
    free; 
    end; 
    end; 打错了
      

  10.   

     function GetComponent(FormName: TForm; ComponentName: String; ComponentClass: TClass) :TComponent;
        var
             I: integer;
        begin
             //确定打开功能窗体中的对应控件
             Result:=nil;
             For I:=0 to FormName.ComponentCount-1 do
             begin
                  if FormName.Components[I] is ComponentClass then
                       if FormName.Components[I].Name=ComponentName then
                          Result:=FormName.Components[I];
             end;
        end;procedure TPublicQuery.ComboBox4Enter(Sender: TObject);
    var
       Temp : TComponent;
    begin
       with StringGrid1 do
       begin
            TComboBox(Sender).Items.Clear;
            if Self.GetState(Cells[1,row])='fkLookup' then
            begin
               Temp:=GetComponent(bm,GetLookADOName(Cells[1,row]),TADOQuery);//获取lookup数据原控件使用权
               with TADOQuery(Temp) do
               begin
                    First;
                    while not Eof do
                    begin
                         TComboBox(Sender).Items.Add(fieldByName(GetLookReslult(Cells[1,row])).AsString);
                         next;
                    end;
               end;
            end;
       end;
    end;
    其中的bm是个pas,所以目前只针对bm(部门),我想动态创建来获得formname,所以
    procedure TMerchandise_info_.BitBtn1Click(Sender: TObject);
    begin
        Application.CreateForm(TPublicQuery,PublicQuery);
        PublicQuery.Edit1.Text:=self.Name;
        PublicQuery.ShowModal;
        PublicQuery.Free;
    end;
    我把formname赋值给了edit1,如何使
     Temp:=GetComponent(bm,GetLookADOName(Cells[1,row]),TADOQuery);//获取lookup数据原控件使用权
    bm得到edit1的值
      

  11.   

    A.pas中点击查询代码
    begin 
        Application.CreateForm(Tb,b); 
        b.Edit1.Text:=self.Name; 
        b.ShowModal; 
        b.Free; 
    end; 
     b.pas中  这是万能查询代码中的部分
    function GetComponent(FormName: TForm; ComponentName: String; ComponentClass: TClass) :TComponent; 
        var 
            I: integer; 
        begin 
            //确定打开功能窗体中的对应控件 
            Result:=nil; 
            For I:=0 to FormName.ComponentCount-1 do 
            begin 
                  if FormName.Components[I] is ComponentClass then 
                      if FormName.Components[I].Name=ComponentName then 
                          Result:=FormName.Components[I]; 
            end; 
        end; procedure Tb.ComboBox4Enter(Sender: TObject); 
    var 
      Temp : TComponent; 
    begin 
      with StringGrid1 do 
      begin 
            TComboBox(Sender).Items.Clear; 
            if Self.GetState(Cells[1,row])='fkLookup' then 
            begin 
              Temp:=GetComponent(a,GetLookADOName(Cells[1,row]),TADOQuery;
              with TADOQuery(Temp) do 
              begin 
                    First; 
                    while not Eof do 
                    begin 
                        TComboBox(Sender).Items.Add(fieldByName(GetLookReslult(Cells[1,row])).AsString); 
                        next; 
                    end; 
              end; 
            end; 
      end; 
    end; 
    这个查询成功了,但目前只是针对a.pas的查询,我现在要应用到所有的pas中,所以
     Temp:=GetComponent(a,GetLookADOName(Cells[1,row]),TADOQuery;
    这里的a是指a.pas,但事实上应用所有菜单的查询的话我要把要查询的菜单名传过来给b.pas
    于是
    begin 
        Application.CreateForm(Tb,b); 
        b.Edit1.Text:=self.Name; 
        b.ShowModal; 
        b.Free; 
    end; 
    //edit1.text得到了要查询的菜单名,但
    Temp:=GetComponent(a,GetLookADOName(Cells[1,row]),TADOQuery;
    中的a如何用edit1.text来替换呢
    Temp:=GetComponent(edit1.text,GetLookADOName(Cells[1,row]),TADOQuery;是错误的,有没有办法
      

  12.   

    var 
    ss:string; 
    begin 
        ss:=edit1.Text; 
        filter_ADO:=ss.adoquery1;(就错了)怎么改
      ss:Tform 就对了
    问题已解决