Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to filter records in TDBGrid?

4,529 views
Skip to first unread message

column

unread,
May 1, 2009, 12:47:54 PM5/1/09
to
Hello,

How to filter records in TDBGrid? This DBGrid is used for browsing and
editing table data. DBGrid is connected to TDataSource and TDataSource
to TIBTable. I use Interbace as database.

Thank you

Ertugrul

unread,
May 27, 2009, 4:01:58 AM5/27/09
to

IBTable1.Filter:='Name='+QuotedSTR('nametobefiltered');
IBTable1.Filtered:=True;

maheshw...@gmail.com

unread,
Jun 26, 2012, 9:53:27 AM6/26/12
to
hi,,
and if I want to implement the same for two fields at the same time?

Thanx.

right...@gmail.com

unread,
Nov 13, 2012, 12:49:06 PM11/13/12
to
Hi,

The filter property of the IBTable is a where clause without the "where" token of an SQL statement.
To filter by more than one field you can use the "AND" or the "OR" operator in the filter.

Per se, IBTable1.Filter:='Name='+QuotedStr('nametobefiltered') + ' AND Age>50'
I often use the Format function for filters as well
IBTable1.Filter := Format('Name = %s and Age > %d', [QuotedStr('NameToBeFiltered'), 50]);

The format function will assign the filter property the string:
'Name = 'NameToBeFiltered' and Age > 50'

I just tested it and it works. I've been doing this for years though.

A good knowledge of SQL will help.

ZurdoSoft

unread,
Feb 15, 2013, 9:38:36 PM2/15/13
to
Yo uso un Dataset y cambio el SQL de acuerdo a la accion en el dbgrid. Por ejemplo cunado pulso el titulo lo ordeno por ese campo. El filter me trajo algunos problemas que son dificiles en el tiempo de depuracion. con la sentencia SQL hace exactamente lo que tu quieres.
0 new messages