?
Solved

Filterin a database at runtime

Posted on 2002-07-16
5
Medium Priority
?
133 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
[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
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 400 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

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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