Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Filter issue
Mon, Oct 22 2007 6:34 PMPermanent Link

peter van mierlo
hi,

i'm looking for a solutions for the following problem. My apps has only tables, no queries.
There's 1 tables which contains 8 fields where the user has to enter the names
of visitors. Now i need to search for a visitors name...which could be in one
of the 8 fields. I think it's much easier when i use a query, but i query versus
tables is a other discussion depending on the needs.

Now i'm looking for a way to make it working by using a filter. One of the reasons why i
use a filter is because all other ''search/filter'' options are based on the use of a combobox
(which contains the items where a user can search for, it could be visitor name, company, license plate)
AND a editbox where the user enters the characters where he wants to search/filter for.
When the users hits the enter key the code below will be excecuted :


 if (key=vk_return) then begin
    // room number (0)
   if RzComboBox_rmtZoekItem.ItemIndex=0 then begin
       dmTables.tbl_layout.Filter:='LOWER(rmt_naam) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';
   end;
   // room name (1)
   if RzComboBox_rmtZoekItem.ItemIndex=1 then begin
       dmTables.tbl_ruimte.Filter:='LOWER(rmt_kamernaam) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';
   end;
   // Start filtering
   dmTables.tbl_ruimte.Filtered:=true;
   if dmTables.tbl_ruimte.RecordCount=0 then begin
       Application.MessageBox('Er zijn helaas géén gegevens gevonden die'+#10+'voldoen aan  de opgegeven zoek kriteria.', 'Mededeling',
MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
       rmtFilterOpheffen;
   end;
   if dmTables.tbl_ruimte.RecordCount>0 then begin
       RzStatusPanel_rmtFilter.caption:='Filter = ACTIEF';
       RzStatusPanel_rmtFilter.Blinking:=true;
       RzStatusPanel_rmtAantal.Caption:='Aantal = '+intToStr(dmTables.tbl_ruimte.RecordCount);
   end;
   if (key=VK_Up) then begin
      dmTables.tbl_ruimte.Prior;
   end;
   if (key=VK_Down) then begin
      dmTables.tbl_ruimte.Next;
   end;
 end;




Tue, Oct 23 2007 3:58 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

peter


I'm not sure what your problem is - all you need to do is extend the existing filter with each of the eight fields with the same sort of syntax you're currently using.

One of my favourite things with DBISAM is that filters and sql are almost identical.

Roy Lambert
Tue, Oct 23 2007 6:52 AMPermanent Link

Peter van Mierlo
Hi Roy,

Can't figure out the right syntax, filtering also supports OR statement. The following test
doesn't work...any suggestions ?

dmTables.tbl_ruimte.Filter:='LOWER(rmt_naw01) or LOWER(rmt_naw02) OR LOWER(rmt_naw03) like LOWER('+QuotedStr
('%'+RzButtonEdit_rmtZoek.Text+'%') +')';

OR

dmTables.tbl_ruimte.Filter:='LOWER(rmt_naw01, rmt_naw02, rmt_naw03) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';



Roy Lambert <roy.lambert@skynet.co.uk> wrote:

peter


I'm not sure what your problem is - all you need to do is extend the existing filter with each of the eight fields with the same sort of syntax you're
currently using.

One of my favourite things with DBISAM is that filters and sql are almost identical.

Roy Lambert
Tue, Oct 23 2007 8:19 AMPermanent Link

"Walter Matte"

dmTables.tbl_ruimte.Filter  :=
 'LOWER(rmt_naw01) like
LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')    OR'  +
 'LOWER(rmt_naw02) like
LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')    OR'  +
 'LOWER(rmt_naw03) like
LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';


Walter

Tue, Oct 23 2007 8:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Walter


Exactly what I was going to say Smiley

Roy Lambert
Tue, Oct 23 2007 12:22 PMPermanent Link

Peter van Mierlo
Hi guys,

thanks for you're help, this is just the solutions i needed.

greetz Peter

Roy Lambert <roy.lambert@skynet.co.uk> wrote:

Walter


Exactly what I was going to say Smiley

Roy Lambert
Tue, Oct 23 2007 12:35 PMPermanent Link

Peter van Mierlo
HI

My reply was to fast...values after rmt_naw01 are not found, only the matching
values which in rmt_naw01.




Hi guys,

thanks for you're help, this is just the solutions i needed.

greetz Peter

Roy Lambert <roy.lambert@skynet.co.uk> wrote:

Walter


Exactly what I was going to say Smiley

Roy Lambert
Tue, Oct 23 2007 1:58 PMPermanent Link

"Walter Matte"

I just used DBSys and Filtered a Table using this type of expression for the
filtered and it worked fine:

 (FieldName1 like '%ABC%') or (FieldName2 like '%ABC%') or (FieldName3 like
'%ABC%')


Walter

"Peter van Mierlo" <p.mierlo@planet.nl> wrote in message
news:CB09F373-D6B9-47CA-B013-6513EE7DDBC9@news.elevatesoft.com...
> HI
>
> My reply was to fast...values after rmt_naw01 are not found, only the
> matching
> values which in rmt_naw01.
>
>
>
>

Tue, Oct 23 2007 4:54 PMPermanent Link

peter van mierlo
hi walter,

i don't think that's the same way using dbsys versus executing the code, it just cut/past
you're code and it's working only for the first field but not for the rest.  When i enter
a visitors name which is in the second field (rmt_naw02) it will not be found

greetz Peter


"Walter Matte" <mattew_@_interlog.com> wrote:


I just used DBSys and Filtered a Table using this type of expression for the
filtered and it worked fine:

 (FieldName1 like '%ABC%') or (FieldName2 like '%ABC%') or (FieldName3 like
'%ABC%')


Walter

"Peter van Mierlo" <p.mierlo@planet.nl> wrote in message
news:CB09F373-D6B9-47CA-B013-6513EE7DDBC9@news.elevatesoft.com...
> HI
>
> My reply was to fast...values after rmt_naw01 are not found, only the
> matching
> values which in rmt_naw01.
>
>
>
>

Tue, Oct 23 2007 5:06 PMPermanent Link

peter van mierlo
Hi,

I just found out whats wrong....

my code :
dmTables.tbl_ruimte.Filter:='LOWER(rmt_naw01) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +') OR LOWER(rmt_naw02) like LOWER('+QuotedStr
('%'+RzButtonEdit_rmtZoek.Text+'%') +') OR LOWER(rmt_naw03) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';

example code :
dmTables.tbl_ruimte.Filter:='LOWER(rmt_naw01) like LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +') OR'  + 'LOWER(rmt_naw02) like LOWER('+QuotedStr
('%'+RzButtonEdit_rmtZoek.Text+'%') +')    OR'  +  'LOWER(rmt_naw03) like  LOWER('+QuotedStr('%'+RzButtonEdit_rmtZoek.Text+'%') +')';

Difference :
OR'  + 'LOWER versus  OR LOWER

Well..you pointed me in the right directions...thanks again for the help

greetz Peter


peter van mierlo <p.mierlo@planet.nl> wrote:

hi walter,

i don't think that's the same way using dbsys versus executing the code, it just cut/past
you're code and it's working only for the first field but not for the rest.  When i enter
a visitors name which is in the second field (rmt_naw02) it will not be found

greetz Peter


"Walter Matte" <mattew_@_interlog.com> wrote:


I just used DBSys and Filtered a Table using this type of expression for the
filtered and it worked fine:

 (FieldName1 like '%ABC%') or (FieldName2 like '%ABC%') or (FieldName3 like
'%ABC%')


Walter

"Peter van Mierlo" <p.mierlo@planet.nl> wrote in message
news:CB09F373-D6B9-47CA-B013-6513EE7DDBC9@news.elevatesoft.com...
> HI
>
> My reply was to fast...values after rmt_naw01 are not found, only the
> matching
> values which in rmt_naw01.
>
>
>
>

Image