Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread What's wrong with this filter code
Tue, Sep 22 2009 2:29 PMPermanent Link

Peter van Mierlo
hi,

I use a dblookupcombobox to select a username, so i have the record id for the selected user
I use a combobox where the user can select the 'state'

When using the filter for searching all matched records for the selected user with this code it works:
  dmTables.tbl_taak.Filter:='taak_nawID='+intTOstr(dmTables.tbl_naw_up.fieldbyname('naw_id').AsInteger);

When using the filter for searching all matched record for the selected 'state' with this code it works:
  dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +')';

When using a combination for searching all matched records for the selected user AND state with
this code it fails.

 dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +') AND' +'taak_nawID=(QuotedStr(intToStr
 (RzDBLookupComboBox_filterNaam.KeyValue))) '

  or the alternative

 dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +') AND' +'taak_nawID=intTOstr(dmTables.tbl_naw_up.fieldbyname
('naw_id').asInteger;

 For some reason the AND is not working.


Regards Peter
Tue, Sep 22 2009 7:38 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< When using a combination for searching all matched records for the
selected user AND state with this code it fails. >>

When you search on each condition separately, are you seeing the rows that
satisfy both conditions ?  If so, then please send me the literal filter
string that you're using (after the Filter property is assigned its value)
along with the tables and I'll take a look.

Thanks,

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Sep 23 2009 2:53 AMPermanent Link

Peter van Mierlo
Hi Tim,

Searching separtly using the condition it works, so if i do a search/filter for the person
it shows the correct result. This is the same with searching on state.

Only the combination doesn't give the correct result. The following example:
Table NAW contains two persones:
- Peter
- Marc

Table STATE contains three states:
- In progress
- Ready
- Exit

Table TASKS contains records where i would like to search for, let say
- record 1 for Peter with the state READY
- record 2 for Marc with the state EXIT

Searching with the combinations :
- search for Peter with state is READY        = combination exists, result FOUND
- search for Peter with state is EXIT           = combination doesn'nt exist but shows record from Marc
- search for Marc with state EXIT               = combination exists, result FOUND
- search for Marc with state READY            = combination doesn'nt exist but shows record from Peter

for filtering on both conditions i use the code below. Where the value from state is choosen with a combobox and the person with a dblookupcombobox

dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +') AND' +'taak_nawID=(QuotedStr(intToStr
(FormFilterUitgebreid.RzDBLookupComboBox_filterNaam.KeyValue))) ';


"Tim Young [Elevate Software]" wrote:

Peter,

<< When using a combination for searching all matched records for the
selected user AND state with this code it fails. >>

When you search on each condition separately, are you seeing the rows that
satisfy both conditions ?  If so, then please send me the literal filter
string that you're using (after the Filter property is assigned its value)
along with the tables and I'll take a look.

Thanks,

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, Sep 23 2009 2:55 AMPermanent Link

Peter van Mierlo



Attachments: data.zip
Wed, Sep 23 2009 4:44 AMPermanent Link

"John Hay"
Peter
> I use a dblookupcombobox to select a username, so i have the record id for
the selected user
> I use a combobox where the user can select the 'state'
>
> When using the filter for searching all matched records for the selected
user with this code it works:
>
dmTables.tbl_taak.Filter:='taak_nawID='+intTOstr(dmTables.tbl_naw_up.fieldby
name('naw_id').AsInteger);
>
> When using the filter for searching all matched record for the selected
'state' with this code it works:
>
dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.
text) +')';
>
> When using a combination for searching all matched records for the
selected user AND state with
> this code it fails.
>
>
dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.
text) +') AND' +'taak_nawID=(QuotedStr(intToStr
>   (RzDBLookupComboBox_filterNaam.KeyValue))) '

You need a space between the AND and taak_nawID

John


Wed, Sep 23 2009 6:04 AMPermanent Link

Peter van Mierlo
Hi John,

I did try this based on your answer but can't get it working:

a space after +') and between the AND doesn't give the searh result
a space after AND and between ' gives a error message
a space after after AND' doesn't give the searh result
a space after +' and before taak_nawID doesn't give the searh result

dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +') AND' +'taak_nawID=(QuotedStr(intToStr
(RzDBLookupComboBox_filterNaam.KeyValue))) '



"John Hay" wrote:

Peter
> I use a dblookupcombobox to select a username, so i have the record id for
the selected user
> I use a combobox where the user can select the 'state'
>
> When using the filter for searching all matched records for the selected
user with this code it works:
>
dmTables.tbl_taak.Filter:='taak_nawID='+intTOstr(dmTables.tbl_naw_up.fieldby
name('naw_id').AsInteger);
>
> When using the filter for searching all matched record for the selected
'state' with this code it works:
>
dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.
text) +')';
>
> When using a combination for searching all matched records for the
selected user AND state with
> this code it fails.
>
>
dmTables.tbl_taak.Filter:='taak_status=('+QuotedStr(RzComboBox_filterStatus.
text) +') AND' +'taak_nawID=(QuotedStr(intToStr
>   (RzDBLookupComboBox_filterNaam.KeyValue))) '

You need a space between the AND and taak_nawID

John
Wed, Sep 23 2009 6:41 AMPermanent Link

"Alessandra"
> I did try this based on your answer but can't get it working:

try with this:

dmTables.tbl_taak.Filter:=
'taak_status='+QuotedStr(RzComboBox_filterStatus.text)+' AND
taak_nawID='+QuotedStr(intToStr
(RzDBLookupComboBox_filterNaam.KeyValue))

Sandra
Wed, Sep 23 2009 10:53 AMPermanent Link

"John Hay"

Peter

Sorry I wasn't clearer - unless it was a typo I meant a space after AND as
shown below.  If you dont have the space the filter looks like
.....ANDtaak_nawId.  The filer should be


dmTables.tbl_taak.Filter:='taak_nawID='+intTOstr(dmTables.tbl_naw_up.fieldby
name('naw_id').AsInteger)+' AND '+
  'taak_status=('+QuotedStr(RzComboBox_filterStatus.text) +')';

John

Wed, Sep 23 2009 2:53 PMPermanent Link

Peter van Mierlo
Hi John,

Thanks for the great help, that was doing the trick, and not so smart
from me not understanding what you mentioned...thanks it works now.

Regards Peter


"John Hay" wrote:


Peter

Sorry I wasn't clearer - unless it was a typo I meant a space after AND as
shown below.  If you dont have the space the filter looks like
.....ANDtaak_nawId.  The filer should be
Image