0

i want to show report with date range
i have code

procedure TForm1.ButtonPreviewClick(Sender: TObject);
begin
    ...
    ADOQuery1.Active := False;
    ADOQuery1.SQL.Text:='';
    ADOQuery1.SQL.Text :='SELECT * FROM tablename WHERE datefield BETWEEN :startdate and :enddate';
    ADOQuery1.Parameters.ParamByName('startdate').DataType:= ftdate;
    ADOQuery1.Parameters.ParamByName('endate').DataType:= ftdate;
    ADOQuery1.Parameters.ParamByName('startdate').value:= datetostr(DateTimePicker1.Date);
    ADOQuery1.Parameters.ParamByName('enddate').value:= datetostr(DateTimePicker2.Date) ;
    ADOQuery1.Active := True;
    QuickRep1.Preview;
    ...
 end;

and i put 4 test records to tablename

number|date
1     |14/8/2015
2     |1/8/2015
3     |31/8/2015
4     |9/8/2015

if i click the button, quick report only showing first record, no matter what date i choose, like this

quickreport

number|date
1     |14/8/2015

with quick report properties
qrband title = qrlabel1 with caption 'quickreport'
qrband column header = qrlabel2 with caption 'number', qrlabel3 with caption'date'
qrband detail = qrdbtext1 & qrdbtext2 with dataset 'adoquery1', datafield 'numberfield' on qrdbtext1 and 'datefield' on qrdbtext2

how to show all data with date range filter?
thanks for your attention

4

0 回答 0