Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Filtering records via OnFilter event
Sat, May 24 2008 9:31 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Here's an interesting one for you. On the main form of my app I have a toolbar button to display the recordcount of the currently active table.

In a common unit I declare CurrentTable: TEDBTable.

As I open / switch to a form I set CurrentTable to its primary table (eg Contacts, Companies etc)

If I set a filter via a string then when I click the button on the main form I'm given the filtered recordcount, BUT if I set a filter via the OnFilter event I'm given the unfiltered recordcount.

The above is true regardless of the stage at which I set   currenttable:=contacts;

Roy Lambert
Sat, May 24 2008 2:56 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< If I set a filter via a string then when I click the button on the main
form I'm given the filtered recordcount, BUT if I set a filter via the
OnFilter event I'm given the unfiltered recordcount. >>

This is as-designed, and is a side-effect of the fact that OnFilterRecord
now performs the filtering client-side and incrementally.  The trade-off is
this - faster, incremental filtering and no counts, or slower, whole-table
filtering with counts.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, May 25 2008 8:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Fair enough - I thought of a workround for it overnight.

Roy Lambert
Wed, Aug 6 2008 9:13 AMPermanent Link

Pierre du Plessis
> Fair enough - I thought of a workaround for it overnight.

Roy,

Could you please share your work around with us?

Regards,
Pierre
Wed, Aug 6 2008 11:33 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Pierre


No problem but I doubt it will be of any assistance. I have a homebrew query generator that allows users to set up filters on the main tables in the app - each main table has a separate form displayed on a page of a pagecontrol. I have a button which when clicked gives the number of records in the "current table".

The filters that are generated are either on columns within the table in which case I use the Filter and the recordcount works or uses columns from several tables in which case I generate a 1 column query of the ID's for the main table and use the OnFilterRecord event to check if the record should be displayed or not.

procedure TContactsForm.ContactsFilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
Accept := sqgContacts.Locate('_ID', DataSet.FieldByName('_ID').AsInteger, []);
end;

I have a global variable declared (CurrentTable: TEDBDBDataSetWinkand simply assign either the main table or the query to it. The button then simply does a CurrentTable.RecordCount.

So in the case above when a filter is used CurrentTable := Contacts, when the OnFilterRecord event CurrentTable := sqgContacts

Roy Lambert [Team Elevate]
Fri, Aug 8 2008 9:31 PMPermanent Link

Pierre du Plessis
Thanks for this Roy!  It may just work.  I'll give it a go.

Pierre
Sat, Aug 9 2008 10:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Pierre


Speeds obviously a bit slower than with a filter but I found it acceptable. The only real niggle was trying to cursor of the bottom of the grid it took a while (maybe 5 seconds) for ElevateDB to figure out there was nothing there. I found that a very acceptable trade off.

Roy Lambert
Image