Solved

Filterin a database at runtime

Posted on 2002-07-16
5
128 Views
Last Modified: 2010-04-04
Hi guys!! I'm here again.

Now I have a simple question but I cannot find the solution, and I hope thay you genius will help me.

How can I specify a filter on a Paradox table at runtime?, i.e. supposing the Customer No changes according the user selection, I want to display a grid
with the invoices of that customer.
The fact is that I can't find the way to write in my source code something like Table1.Filter := ....

So, can anybody of you send me the right syntax. I think it's easy, but so far I couldn't solve it.

Thanks again

Juan Carlos
0
Comment
Question by:juank
5 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7158389
Table.Filter:='some filter goes here';
Table.Filtered:=True;




Good luck!!


0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7158396
to expand on my last comment:

Take the animals table that ships with Delphi (listed in DBDEMOS)... drop that on a form with a TTable,Datasource and a DBGrid. Now in a button click event add this code:

Table1.Filter:='Size>2';
Table1.Filtered:=True;

Now run the project... before hitting the button, you'll see every listing i the table, afterwards you'll only see those where Size>2. Alternatively, you could use a TQuery, assigning it as Dataset to the DataSource. This way you could do LIKE and ORDERBY queries as well.


Good luck!!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7158721
you can also do a master-detail relationship between
customer-tabel and invoices-table

just set on the invoices-table as mastersource the datasource of the customer-table and set the masterfields
with the dialog there

no filter is then required,
delphi does this now automatically

meikl ;-)
0
 
LVL 3

Accepted Solution

by:
marcoszorrilla earned 100 total points
ID: 7158723
More Examples with a Tedit and a Variable.

Table1.Filter:='CodCustomer ='+QuotedStr(Edit1.Text);
Table1.Filtered:=True;

Table1.Filter:='CodCustomer ='+QuotedStr(MyVar);
Table1.Filtered:=True;

Best Regards.
Marcos.
0
 

Author Comment

by:juank
ID: 7165750
That's exactly what I was lookig for.

Thanks!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

14 Experts available now in Live!

Get 1:1 Help Now