mandag den 20. juli 2009

Getting field values of more than one data source when calling a menu item

When a form has called another form (the user has opened a form by clicking a button in another form), you sometimes need to get information from the calling form.

The traditional way is to use element.args().record(); but this construction only allows for transferring ONE datasource at a time.

Sometimes it would be nice to be able to transfer more than one datasource.
This is an example of how that can be done.

The code must be implemented in the


-method of the CALLED form:

SysSetupFormRun s;
APMObjectTable apmObjectTable;
int dataSourceNo;

// Determine value of fields APMProductId and APMModelId of APMObjectTable record
// which might have been active at the time of pressing CTRL+F4 in the previous form
// (CTRL+F4 on model field in form APMCustOverview)
s = element.args().caller();
if (s)
    for (datasourceNo = 1; dataSourceNo <= s.dataSourceCount(); dataSourceNo++)
        if (s.dataSource(dataSourceNo).cursor().TableId == tableNum(APMObjectTable))
            apmObjectTable = s.dataSource(dataSourceNo).cursor();

Ingen kommentarer:

Send en kommentar