Solved

Filterin a database at runtime

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Correct Component for Shopping Cart. 2 105
Unique identifier on a terminal server (rdp) 4 52
Convert MS Word document to a PDF file 9 78
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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