//示例如下:后面有注释!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, StdCtrls, Db, DBTables, ComCtrls;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
Button1: TButton;
DBGrid1: TDBGrid;
DateTimePicker1: TDateTimePicker;
procedure Button1Click(Sender: TObject);
procedure Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Table1.Filtered := True;
Table1.Active := not Table1.Active;
end;
procedure TForm1.Table1FilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
Accept := table1.FieldValues['SaleDate']>self.DateTimePicker1.Date;//用DateTimePicker返回的日期(Tdatetime)
//accept为 Boolean 类型
end;
//一定先要把Table1的Filtered属性改为True
end.
我是在D4下用demos 中的ORDERS.DB试的,绝对没有问题