You mean a query in the report?
Stored procedures, I didn't know SQLite had that capability.
Can you give an explain in more detail how you used the query for your report header?
I'm not sure SQLite supports stored procedures. I was just citing an example.
Let's consider a hypothetical example. If the report header contains say Customer name while the report detail contains Orders, use a query to obtain the customer name from the customer table & save it to a report variable like TRLLabel AND then use databound report variables like TRLDBText in the detail section to display the contents of the Orders table.
The two tables must be linked on a CustNo private key.
To repeat this for many pages, use two loops
a) an outer loop that retrieves the Customer names
b) an inner loop that fills the detail band
Call the Fortes report unit from inside the inner loop & make it display ONLY the current dataset in the inner loop.
So at any point in time when the report is called, the report variables will contain the current customer number & his orders.
In my code below, the line
// Query the stored procedure 'MEMBER_TOTALS'
frmPrintMember.RLlblTotal.Caption
:= CountMember('MEMBER_TOTALS', strBegin, strEnd);
is where I query another table or a stored procedure to get a value I need for my report. My report unit contains no code at all. All the work is done in the procedure below which prepares & then displays the report
{----------------------------------------------------------------------
Procedure for the Member report
-----------------------------------------------------------------------}
procedure TfrmMember.PrintPreviewClick(Sender: TObject);
var
strBegin, strEnd, strNow: string;
begin
// Set the default year of the 'Year' spin button to the current year
strNow := DateToStr(Now); // Convert the current datetime value to a string
strBegin := '01/01/' + Copy(strNow, 7, Length(strNow)) + '';
strEnd := '31/12/' + Copy(strNow, 7, Length(strNow)) + '';
// Create the print Member form, show it modally & finally destroy it
frmPrintMember := TfrmPrintMember.Create(Self);
try
// Get the values for the lookup fields
frmPrintMember.RLlblCountry.Caption := dblkupCountry.Caption;
frmPrintMember.RLlblPartner.Caption := dblkupPartner.Caption;
// Query the stored procedure 'MEMBER_TOTALS'
frmPrintMember.RLlblTotal.Caption
:= CountMember('MEMBER_TOTALS', strBegin, strEnd);
// Display the report on the screen showing the current record
with dmDataMod.dsMember do
begin
frmPrintMember.RLReport.Preview();
frmPrintMember.RLReport.ClosePreview;
end;
finally
FreeAndNil(frmPrintMember);
end;
end;