Solved

Get number of record after FILTER usig TwwFilterDialog

Posted on 2004-09-10
10
1,127 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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