How do I loop through a table, create a temp table with distinct fields then run a query on that temp table?
Posted on 2008-09-30
Using Delphi 7 with Paradox/Local SQL.
I'm using a component (SMExport) which exports from a dataset to an excel file.
My table contains a client code field and a type field by which I want to filter. There are only two types and i'm running two separate queries with a function for each type where the component generates the excel file. This gives me two files filtered by type, but I need one file per client code. I'm assuming I need to loop through the main table, create a temp table where the records only have unique client code, then run the query on the temp table...repeat...but I have no idea how. Hope this made sense.
Here's my code for the first function:
with Leads_Datamodule do
qryTransferTechLeads.SQL.Add('WHERE LeadType ='+QuotedStr('Technicians'));