At 03:09 PM 12/22/2008, TOM HART wrote:

.. is there a way, with property command, to sort by more than one column.


Yes, you can!

Depending on what you are trying to do. Because of its cool features,
if you are simply using the DB Grid to display data, you may define
the DB Grid based on a TEMPORARY VIEW. Then, you may define a few
buttons with various SORT options and dynamically sort the DB Grid
using the following PROPERTY commands:

     PROPERTY TABLE DBGridTableName CLOSE
     -- Resort the driving table/view
     PROPERTY TABLE DBGridTableName OPEN

Here' how:

01. Create a TEMPORARY VIEW

    Example: (Based on RRBYW14 Sample Database)

    -- Start
    SET ERROR MESSAGE 677 OFF
    DROP VIEW tCustomer
    SET ERROR MESSAGE 677 ON
    CREATE TEMPORARY VIEW `tCustomer` AS SELECT +
    CustID,Company,CustAddress,CustCity,CustState, +
    CustZip,CustPhone,CustFax,ModLevel,LastUpdateDate, +
    LastUpdateTime,LastOrderDate,CustURL,CustEMail, +
    CustStatus,PaymentTerm,CreditLimit FROM Customer
    COMMENT ON VIEW `tCustomer` IS 'Temporary Customer View'
    RETURN
    -- End

02. Create a new form based on tCustomer view

    While in Form Designer, make sure to include the same
    view definition (Step 01) as "On Before Design Action".

    This will help for future form modifications without
    being concerned about defining the required TEMP View
    before bringing up the form in form designer.

    Customize the DB Grid Columns and options as you wish.

04. While in Form Designer:

    While in Form Designer, make sure to include the same
    view definition (Step 01) as "On Before Start EEP".

    This will help run the form without being concerned
    about defining the required TEMP View before using the
    EDIT USING formname command.

05. While in Form Designer:

    Place a Bit Button with the following Caption and the
    Custom EEP:

    Button Caption: Sort by Company
    Custom EEP:
    -- Start
    PROPERTY TABLE tCustomer CLOSE
    DROP VIEW tCustomer
    CREATE TEMPORARY VIEW `tCustomer` +
    AS SELECT +
    CustID,Company,CustAddress,CustCity,CustState, +
    CustZip,CustPhone,CustFax,ModLevel,LastUpdateDate, +
    LastUpdateTime,LastOrderDate,CustURL,CustEMail, +
    CustStatus,PaymentTerm,CreditLimit +
    FROM Customer ORDER BY Company
    PROPERTY TABLE tCustomer OPEN
    RETURN
    -- End

06. While in Form Designer:

    Place a Bit Button with the following Caption and the
    Custom EEP:

    Button Caption: Sort by CustState and Company
    Custom EEP:
    -- Start
    PROPERTY TABLE tCustomer CLOSE
    DROP VIEW tCustomer
    CREATE TEMPORARY VIEW `tCustomer` +
    AS SELECT +
    CustID,Company,CustAddress,CustCity,CustState, +
    CustZip,CustPhone,CustFax,ModLevel,LastUpdateDate, +
    LastUpdateTime,LastOrderDate,CustURL,CustEMail, +
    CustStatus,PaymentTerm,CreditLimit +
    FROM Customer ORDER BY CustState, Company
    PROPERTY TABLE tCustomer OPEN
    RETURN
    -- End

06. While in Form Designer:

    Place a Bit Button with the following Caption and the
    Custom EEP:

    Button Caption: Sort by CustStatus,CreditLimit DESC,Company
    Custom EEP:
    -- Start
    PROPERTY TABLE tCustomer CLOSE
    DROP VIEW tCustomer
    CREATE TEMPORARY VIEW `tCustomer` +
    AS SELECT +
    CustID,Company,CustAddress,CustCity,CustState, +
    CustZip,CustPhone,CustFax,ModLevel,LastUpdateDate, +
    LastUpdateTime,LastOrderDate,CustURL,CustEMail, +
    CustStatus,PaymentTerm,CreditLimit +
    FROM Customer ORDER BY CustStatus,CreditLimit DESC,Company
    PROPERTY TABLE tCustomer OPEN
    RETURN
    -- End

07. Save the form.

08. Test the form using "EDIT USING formname" command.

    This will be a totally automated form using the dynamic
    ORDER BY (sort) options, as you wish, using the PROPERTY
    command.

That's all there is to it!

Have fun.

Very Best R:egards,

Razzak.


Reply via email to