Solved

Filterin a database at runtime

Posted on 2002-07-16
5
131 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 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

Independent Software Vendors: 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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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