Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Filters
Fri, Aug 10 2007 5:35 AMPermanent Link

"Petrus van Breda"
Hi

I want to add the filter expression in a DBMemo field and call it when
needed. The expression looks something like the one below:

ClientTable.Filter := '(BirthMonth =
'+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')and(Access <>
'+QuotedStr('X')+')and (Enddate >= '+QuotedStr(DateToDBISam(Now))+')';

All work fine when I use it as above, but when I call it from a memo field I
get errors. I presume it is a simple mistake but I can not find it.

Any help will be appreciated.

Regards

Petrus

Fri, Aug 10 2007 5:42 AMPermanent Link

Chris Erdal
"Petrus van Breda" <petrus@spsoftdev.com> wrote in news:5A6C2543-C719-4747-
9775-7352B8F5B57C@news.elevatesoft.com:

> I get errors

Petrus,

 could you be a little more precise here?

--
Chris
(XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3)

Fri, Aug 10 2007 5:53 AMPermanent Link

"Petrus van Breda"
Hi

I added the following to a Memofield in a table:
'(BirthMonth = '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')and(Access <>
'+QuotedStr('X')+')and (Enddate >= '+QuotedStr(DateToDBISam(Now))+')'

Now I want to use it when I filter the records:

Table1.Filter := DBMemo1.Text;
or using
Table1.FieldByName('FilterInfo').AsString)
Table1.Filtered := True;

All work fine if I don't use QuotedStr, but I need to collect some info
other fields on the form as well and include them in the filter.

Hope this clarify it better?

Regards

Petrus

"Petrus van Breda" <petrus@spsoftdev.com> wrote in message
news:5A6C2543-C719-4747-9775-7352B8F5B57C@news.elevatesoft.com...
> Hi
>
> I want to add the filter expression in a DBMemo field and call it when
> needed. The expression looks something like the one below:
>
> ClientTable.Filter := '(BirthMonth =
> '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')and(Access <>
> '+QuotedStr('X')+')and (Enddate >= '+QuotedStr(DateToDBISam(Now))+')';
>
> All work fine when I use it as above, but when I call it from a memo field
> I get errors. I presume it is a simple mistake but I can not find it.
>
> Any help will be appreciated.
>
> Regards
>
> Petrus
>

Fri, Aug 10 2007 6:03 AMPermanent Link

Chris Erdal
"Petrus van Breda" <petrus@spsoftdev.com> wrote in
news:AF12980E-70D7-4176-BB13-D6B87A3B2C4B@news.elevatesoft.com:

> Hi
>
> I added the following to a Memofield in a table:
> '(BirthMonth =
> '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')and(Access <>
> '+QuotedStr('X')+')and (Enddate >= '+QuotedStr(DateToDBISam(Now))+')'
>
> Now I want to use it when I filter the records:
>
> Table1.Filter := DBMemo1.Text;
> or using
> Table1.FieldByName('FilterInfo').AsString)
> Table1.Filtered := True;
>
> All work fine if I don't use QuotedStr, but I need to collect some
> info other fields on the form as well and include them in the filter.
>
> Hope this clarify it better?

A little Wink

But could you give us the exact error message(s)?

--
Chris
(XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3)

Fri, Aug 10 2007 6:18 AMPermanent Link

"Petrus van Breda"
Hi Chris

The error is a DBISAM Engie Error #10051 Filter error for the table
'client' - Expected column name but instead found QuotedStr in filter
expression at line 1, column 18.

Petrus

"Chris Erdal" <chris@No-Spam-erdal.net> wrote in message
news:Xns99887A11FC85B14torcatis@64.65.248.118...
> "Petrus van Breda" <petrus@spsoftdev.com> wrote in
> news:AF12980E-70D7-4176-BB13-D6B87A3B2C4B@news.elevatesoft.com:
>
>> Hi
>>
>> I added the following to a Memofield in a table:
>> '(BirthMonth =
>> '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')and(Access <>
>> '+QuotedStr('X')+')and (Enddate >= '+QuotedStr(DateToDBISam(Now))+')'
>>
>> Now I want to use it when I filter the records:
>>
>> Table1.Filter := DBMemo1.Text;
>> or using
>> Table1.FieldByName('FilterInfo').AsString)
>> Table1.Filtered := True;
>>
>> All work fine if I don't use QuotedStr, but I need to collect some
>> info other fields on the form as well and include them in the filter.
>>
>> Hope this clarify it better?
>
> A little Wink
>
> But could you give us the exact error message(s)?
>
> --
> Chris
> (XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3)
>
>

Fri, Aug 10 2007 7:25 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Petrus


You seem to be expecting the filter to evaluate QuotedStr but it won't do that. You have to supply a simple text expression. So if you want to store it in a memo and use it later you'll have to work out the quotes that are needed and put them in yourself. If, as you say you're picking up data from elsewhere and incorporating it into a filter then just put the placeholder in the memo field and do something like

tmpfilter := table.memofield.asstring;
tmpfilter := StringReplace(tmpfilter,placeholder,QuoterStr(newvalue),[]);
table.filter := tmpfilter;

Roy Lambert
Fri, Aug 10 2007 9:32 AMPermanent Link

"Petrus van Breda"
Hi

I tried what was suggested but could not get it resolved. Please see screen
shots in binaries.

1. Screen.jpg show you the screen where the memo field is. The data is:
   '(BirthMonth = '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')'

2. Insideprogram.JPG is where I did the following command:
   ShowMessage('(BirthMonth =
'+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')');
   This show the string correctly as it is processed by Delphi.

3. Memofield.jpg is where I use the information storred in the memo field.
   Info is: '(BirthMonth = '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')'
   ShowMessage(DBMemo1.Text);

As can be seen number 3 display the information wrong and I need it to be
displayed as in number 2 to be able to work correctly.

Any suggestions as to what is wrong?

Thanks

Petrus

Fri, Aug 10 2007 9:44 AMPermanent Link

"Robert"

"Petrus van Breda" <petrus@spsoftdev.com> wrote in message
news:61D549BA-4D26-42A2-941B-0FE4106FC77C@news.elevatesoft.com...
> Hi
>
> I tried what was suggested but could not get it resolved. Please see
> screen shots in binaries.
>
> 1. Screen.jpg show you the screen where the memo field is. The data is:
>    '(BirthMonth = '+QuotedStr(Uppercase(SPAdvComboBox1.Text))+')'
>

As others have indicated, you do not place the literal 'QuotedStr' in the
filter, but instead the actual result of the QuotedStr function.

var s : string;
s := 'Robert';
Query.Filter := 'Name = ' + QuotedStr(s);

If you now look at Query.Filter, you should have

Name = 'Robert'

R


Fri, Aug 10 2007 10:33 AMPermanent Link

Chris Erdal
"Petrus van Breda" <petrus@spsoftdev.com> wrote in
news:61D549BA-4D26-42A2-941B-0FE4106FC77C@news.elevatesoft.com:

> Any suggestions as to what is wrong?
>

Petrus,

 What is wrong is that Delphi is a pre-compiled language, and it cannot
interpret Pascal code after compilation without a little help.

If you have a limited number of Delphi keywords that are liable to appear
in your scripts then you could, as Roy suggested, analyse your memo text
looking for these particular words and rebuild the text, substituting
whatever is necessary using a multiple IF... THEN ELSE IF ... THEN ELSE
IF... process.

If "anything goes" in your memo texts, then you'll need to include
something able to interpret scripts on the fly.

I Googled around and perhaps something like this may help:

http://www.dream-com.com/dscriptdesc.html

--
Chris
(XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3)

Fri, Aug 10 2007 1:10 PMPermanent Link

"Petrus van Breda"
Hi Everybody

Thank you for all the suggestions and help. Seems that I got it solved. Are
able to most of the reports and create them on the fly without problems.

Regards

Petrus

Image