在unit2那个地方写上:
uses unit1;
procedure TForm2.Button2Click
begin
     Form1.Table1.Active:=False;
end;

解决方案 »

  1.   

    对不起,说错了!应该是:Table2.Active:=False;不行,提示“Undeclared indentifier 'Table2'
               "Cannot assign to a read-only property"
      

  2.   

    你是不是用了数据库控件:TTable?
    TTable.Active是一个可读写的属性,不应该上面的提示!你试试Table2.Close;
    Specifies whether or not a dataset is open.
    property Active: Boolean;
    Description
    Use Active to determine or set whether a dataset is populated with data. When Active is False, the dataset is closed; the dataset cannot read or write data and data-aware controls can not use it to fetch data or post edits. When Active is True, the dataset can be populated with data. It can read data from a database or other source (such as a provider). Depending on the CanModify property, active datasets can post changes.
    Setting Active to True
    Generates a BeforeOpen event.
    Sets the dataset state to dsBrowse.
    Establishes a way to fetch data (typically by opening a cursor).
    Generates an AfterOpen event.
    If an error occurs while opening the dataset, dataset state is set to dsInactive, and any cursor is closed.
    Setting Active to False:
    1 Triggers a BeforeClose event.
    2 Sets the State property to dsInactive.
    3 Closes the cursor.
    4 Triggers an AfterClose event.
    An application must set Active to False before changing other properties that affect the status of a database or the controls that display data in an application.
    Note: Calling the Open method sets Active to True; calling the Close method sets Active to False.
      

  3.   

    是的。用了close;
    cannot...没有了,但第一个提示依然有
      

  4.   

    DD88(咖啡杯里的毛巾)
    你的table2是不是不在同一个文件中?
    你几个文件的名称是什么?
    uses unit1;
      

  5.   

    是的。Main_Window
    我在implementation中申明了uses Main_Window;
      

  6.   

    比如说table2在main_window的form1上
    则调用要写:Form1.table2.Close;
      

  7.   

    我用的是:Main_window.table2.Close;
      

  8.   

    你那个form是不是叫main_window,
    还是你那个单元文件叫:main_window.pas
    必须试form的名字!
      

  9.   

    你用QQ的吗?要不我把原吗传过来,OK?
      

  10.   

    你的程序错了mainform.table.close
      

  11.   

    改成MainWindow.Table2.close;就可以了。
    单元名字和FORM的名字搞混了,呵呵。