Solved

Get number of record after FILTER usig TwwFilterDialog

Posted on 2004-09-10
10
1,114 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 249
How to fill array with TArray.Create? 14 68
Downloading email attachments 2 54
Working with hours 3 31
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now