Solved

Filterin a database at runtime

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

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

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

20 Experts available now in Live!

Get 1:1 Help Now