Solved

Get number of record after FILTER usig TwwFilterDialog

Posted on 2004-09-10
10
1,143 Views
Last Modified: 2007-11-27
I want to get a number of record (ADODataSet) after user filter the recordset using TwwFilterDialog or could any of you can recommend me a suitable Filter Component.

after open dataset may be record count = 300
after filter dataset may be filtered record count = 100, how can I get this value.
0
Comment
Question by:soapsiam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12024285
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
ID: 12024480
This is already implemented in TwwFilterDialog...

The result is correctly returned if you use a TwwTable or twwquery query but as you're using AdoDatasets you have to change the FilterPropertyOption in TwwFilterDialog to fdUseFilterProp. (This is the reccomended by InfoPower using Ado).

Then this will show the real filtered recordcount.

procedure TForm1.Button1Click(Sender: TObject);
begin
wwfilterdialog1.FilterPropertyOptions.DatasetFilterType :=fdUseFilterProp;
wwfilterdialog1.Execute;
label1.Caption := inttostr(adotable1.RecordCount);
end;

0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12026427
TwwFilterDialog? Never used it anyway.

Unless I'm mistaken, an ADODataset has "Filter" and "Filtered" properties. If Filtered is true, the filter will be applied and if I'm not mistaken, this will update the recordcount.

If not, set a bookmark on the current record, disable the controls, go to the first record and then walk through the whole recordset counting every record until EOF. Go back to the bookmarked record, enable the controls and you're done. But I think RecordCount would work if you use the Filter property.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12026482
-->  But I think RecordCount would work if you use the Filter property.
Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.

BTW TwwFilterDialog is a InfoPower component. A customizable filter dialog for filtering on datasets fields. And as already said, this feauture is already supported by it just without code additions....

F68 ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12027024
>this feauture is already supported by it just without code additions....

well, then my link above is not needed . . .

meikl ;-)
0
 

Expert Comment

by:iman_a_r
ID: 12027465
Hi,
I had the same problem with Filte and prefer to use SQL inseted of Filter.

You can use Queries component insted of Tables.
Using Query and Table is the same.

Let have an example.

-------------------- With table
Table.Name:='table1';
...
Table.Filter='Age=10';
Table.Filtered=True;

------------------------------ With Query
Query.SQL.add('Select * from Table1 where Age=10');


if it can be a good solution i can give you a sample.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12028411
@iman_a_r,
The use of a filter should, in general, improve the performance. If the recordset is very large, and still large after a filter is applied, using a filter on the query performs faster than re-querying the recordset with an additional filter. Especially if the database is located on another system and you have to use the network to send over the records. The ADODataset.Filter will execute the filter on the client, thus not causing any more network traffic to the server. Your suggestion would demand another large amounts of records to be sent back to the client.
Thus, in my personal view, inefficient for client-server solutions. But okay for local databases.

@f68,
> Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.
It does? And the ADODataset.Recordset.RecordCount property then? The ADODataset is just a TRecordset wrapper around the ADO components. If I'm not mistaken, the TADODataset will return the value from the _Recordset underneath. The filter itself will also be passed to the _Recordset, and I would expect MicroSoft to be smart and return the right amount of records after the filter has been set.
Unfortunately, I can't test it right now...
0
 
LVL 6

Expert Comment

by:bpana
ID: 12028692
@f68,
> Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.

That's not true. Workshop_Alex is right.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12036132
@bpana, of course I'm right :D
0
 
LVL 1

Author Comment

by:soapsiam
ID: 12061948
I use TwwFilterDialog as it is allow end user to buid their own filter condition so I don't have to write it.

As I use Client side cursor of ADO, if using .Filter := 'Some thing here';
and Filtered := True; It update RecordCount property. But that is not the case with TwwFilterDialog.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question