Home > Archive > Programming with dBASE > October 2005 > filtering









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author filtering
Bill

2005-10-11, 7:27 am

When I use this filter clause, I get an error if I am using data with an
apostrophe in the name like ex. dave's . Everythings works fine If I use
data without an apostrophe like ex. Dave.
Here is the filter clause

if len(trim(form.c_name.value)) > 0
form.plus_and() // complex filter clause
form.filterclause := ltrim(form.filterclause) + "CON_BUSINESS =
"+"'"+trim(form.c_name.value)+"'"+" "
endif

What is causing this problem with the apostrophe in my data.


Ivar B. Jessen

2005-10-11, 7:27 am

On Mon, 10 Oct 2005 14:32:15 -0500, "Bill" <toquerrio@hotmail.com> wrote:

>When I use this filter clause, I get an error if I am using data with an
>apostrophe in the name like ex. dave's . Everythings works fine If I use
>data without an apostrophe like ex. Dave.
>Here is the filter clause
>
> if len(trim(form.c_name.value)) > 0
> form.plus_and() // complex filter clause
> form.filterclause := ltrim(form.filterclause) + "CON_BUSINESS =
>"+"'"+trim(form.c_name.value)+"'"+" "
> endif
>
>What is causing this problem with the apostrophe in my data.



See the OLH on filter:

"If the filter expression contains a quoted string that contains an
apostrophe, precede the apostrophe with a backslash. Note that the single
quote used in SQL expressions for strings and the apostrophe are
represented by the same single quote character on the keyboard. For
example, if this is the rowset and you want to display rows with the
Lastname "O’Dell":

this.filter := "Lastname = 'O'Dell'"


Ivar B. Jessen
Bill

2005-10-11, 7:27 am

My filter clause is set to a field in a table with a list of names. I don't
know when or which fields will have an apostrophe. This filter clause lets
the user filter which name to print a report on. the names are selected from
a combobox datalinked to a table.
"Ivar B. Jessen" <bergishagen@it.notthis.dk> wrote in message
news:39jlk11ker31q8v
bfifqilrb7st4sm5lr1@
4ax.com...
> On Mon, 10 Oct 2005 14:32:15 -0500, "Bill" <toquerrio@hotmail.com> wrote:
>
>
>
> See the OLH on filter:
>
> "If the filter expression contains a quoted string that contains an
> apostrophe, precede the apostrophe with a backslash. Note that the single
> quote used in SQL expressions for strings and the apostrophe are
> represented by the same single quote character on the keyboard. For
> example, if this is the rowset and you want to display rows with the
> Lastname "O'Dell":
>
> this.filter := "Lastname = 'O'Dell'"
>
>
> Ivar B. Jessen



Roger Sauer

2005-10-11, 7:27 am

You can test for the presence of an apostophe in form.c_name.value and adjust the filter expression accordingly.

Roger

Bill Wrote:

> My filter clause is set to a field in a table with a list of names. I don't
> know when or which fields will have an apostrophe. This filter clause lets
> the user filter which name to print a report on. the names are selected from
> a combobox datalinked to a table.
> "Ivar B. Jessen" <bergishagen@it.notthis.dk> wrote in message
> news:39jlk11ker31q8v
bfifqilrb7st4sm5lr1@
4ax.com...
>
>


Bill

2005-10-11, 7:27 am

can you explain how?
"Roger Sauer" <rwsauer@_nospam_.comcast.net> wrote in message
news:eeNc43dzFHA.352@news-server...
> You can test for the presence of an apostophe in form.c_name.value and
> adjust the filter expression accordingly.
>
> Roger
>
> Bill Wrote:
>
>



Roland Wingerter

2005-10-11, 7:27 am

Roger Sauer wrote

> You can test for the presence of an apostophe in form.c_name.value and
> adjust the filter expression accordingly.

------
Perhaps this sample will help.

set proc to :dUFLP:stringEx.cc addi
cValue = [L'amour de Monsieur O'Neill]
cValue1 = new stringex().strTran(cValue, ['], ['])
? cValue1 // "L'amour de Monsieur O'Neill"

Roland


Ken Mayer [dBVIPS]

2005-10-11, 7:27 am

Bill wrote:
> When I use this filter clause, I get an error if I am using data with an
> apostrophe in the name like ex. dave's . Everythings works fine If I use
> data without an apostrophe like ex. Dave.
> Here is the filter clause
>
> if len(trim(form.c_name.value)) > 0
> form.plus_and() // complex filter clause
> form.filterclause := ltrim(form.filterclause) + "CON_BUSINESS =
> "+"'"+trim(form.c_name.value)+"'"+" "
> endif
>
> What is causing this problem with the apostrophe in my data.


It's the issue with delimiters. If you break that statement down, you get:

CON_BUSINESS = 'Dave's'

That's not very useful. Try:

form.filterclause := ltrim(form.filterclause) + "CON_BUSINESS =
["+trim(form.c_name.value)+"]"

Which will give you:

CON_BUSINESS = [Dave's]

And that should work.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
Roger Sauer

2005-10-12, 11:24 am

As Roland pointed out, there's a nice character-replacement routine in the DUFLP. Put the line "set proc to :dUFLP:stringEx.cc additive" at the start of your program, then

if len(trim(form.c_name.value)) > 0
form.plus_and() // complex filter clause
cNewValue = new stringex().strTran(form.c_name.value, ['], ['])
form.filterclause := ltrim(form.filterclause) + ;
"CON_BUSINESS ="+"'"+trim(cNewValue)+"'"+" "
endif

Roger

Bill Wrote:

> can you explain how?
> "Roger Sauer" <rwsauer@_nospam_.comcast.net> wrote in message
> news:eeNc43dzFHA.352@news-server...
>
>


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com