But in the current project you already see a preview screen.
script with comments
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
Results: TDataSet;
s1, s2, s3: string;
i, iTimes: integer;
begin
SQLExecute('DELETE FROM bc_temp'); // clear table from previous data
SQLExecute('PRAGMA synchronous = OFF'); // to increase speed of INSERTs
try
SQLQuery('SELECT Company, Address, xTimes FROM BC', Results); // gets data from BC table
while not Results.Eof do
begin
// read data
s1 := Results.FieldByName('Company').asString;
s2 := Results.FieldByName('Address').asString;
s3 := Results.FieldByName('xTimes').asString;
if s1 <> '' then s1 := '''' + escape_special_characters(s1) + '''' else s1 := 'NULL';
if s2 <> '' then s2 := '''' + escape_special_characters(s2) + '''' else s2 := 'NULL';
// how many times
iTimes := 0;
if ValidInt(s3) then iTimes := StrToInt(s3);
// write data to bc_temp iTimes times for every record from "BC"
for i := 1 to iTimes do
SQLExecute('INSERT INTO bc_temp (Company, Address) VALUES ('+s1+','+s2+')');
Results.Next;
end;
finally
SQLExecute('PRAGMA synchronous = FULL');
end;
end;
You must use temporary table (bc_temp), because report works only with data from database, so using this table we prepared data for this non standard report.
Dmitry.