Topic: [Script] Send in the report, only the selected records in TableGrid

Send in the report, only the selected records in TableGrid


procedure Form1_bSQLReport_OnClick (Sender: string; var Cancel: boolean);
var
    i,c: integer;
    s: string;
begin
    s := '';
    Form1.bSQLReport.dbSQL := 'SELECT lastname, firstname, strftime(''%m/%d/%Y'', dateofbirth) as dateofbirth FROM employees';
    c := Form1.GridEmployees.RowCount-1;

    for i := 0 to c do
    begin
        if Form1.GridEmployees.Selected[i] then s := s + 'employees.id='+IntToStr(Form1.GridEmployees.dbIndexToID(i)) + ' OR ';
    end;

    if s <> '' then
    begin
        SetLength(s, Length(s)-4);
        Form1.bSQLReport.dbSQL := Form1.bSQLReport.dbSQL + ' WHERE ' + s;
    end;
end;


begin
    Form1.GridEmployees.Options := Form1.GridEmployees.Options + goMultiSelect;
end.

Download project:
http://myvisualdatabase.com/forum/misc. … download=1

Dmitry.