Monday, July 14, 2014

Create Run-Time Lookup Forms

public void lookup()
{
   
    Query                   query          = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;

    // Create an instance of SysTableLookup where 'this'
    // is the current form control.
    SysTableLookup sysTableLookup =
        SysTableLookup::newParameters(tableNum(custTable), this);
    ;

    // Add fields to be shown in the lookup form.
    sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
    sysTableLookup.addLookupField(fieldNum(CustTable, Name));

    // Limit and arrange the data selection.
    queryBuildDataSource = query.addDataSource(tableNum(CustTable));
    queryBuildRange = queryBuildDataSource.addRange(
        fieldNum(CustTable, AccountNum));
    queryBuildRange.value('100..2000');
    sysTableLookup.parmQuery(query);

    // Perform the lookup.
    sysTableLookup.performFormLookup();

    //Don't call super() (commented out in the code).
    //   super()
}

No comments:

Post a Comment