Preparing the Data Source

To provide the correct data for the drilldown report minor changes to the printing loop are neccessary.

Relation(s)

Drilldown can only be used when relations are declared. For drilldown reports use the function LlDbAddTableRelationEx(). This function has 2 additional parameters: pszKeyField and pszParentKeyField for the key field of the child table and the key field of the parent table, so a unique assignment can be made.

Further information can be found in the description of the function LlDbAddTableRelationEx().

Please note, that the key fields must contain the table name as a prefix, for example "Customers.CustomerID".

Example:

Declare the relation between 'Customers' and 'Orders' table for drilldown using the northwind sample.

// add relation

CString sParentField = pMyDrillDownParameters->_pszSubreportTableID +
                _T(".")+pMyDrillDownParameters->_pszKeyField; //Orders.CustomerID
CString sChildField = pMyDrillDownParameters->_pszTableID + _T(".") +
                pMyDrillDownParameters->_pszSubreportKeyField; //Customers.OrderID
::LlDbAddTableRelationEx(hJob,
                pMyDrillDownParameters->_pszSubreportTableID,    // "Orders"
                pMyDrillDownParameters->_pszTableID,     // "Customers"
                pMyDrillDownParameters->_pszRelationID, _T(""),
                sParentField, sChildField);

Datasource

For each drilldown report the datasource should be filtered differently, because only the data related to the parent record that has been clicked is needed.

For example you want to create a drilldown structure from "Customers" to "Orders". In this case the parent table should show all customers. A click on one customer should show only the corresponding orders related to this special customer. Therefor the datasource must only contain the orders from this customer. All necessary information for filtering the child table can be found in the structure 'scLlDrillDownJob'.