Home > Archive > Programming with dBASE > November 2005 > filtering part of field value









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 part of field value
Moses Hanna

2005-11-11, 7:23 am

Hi
I have a table with ID field character. it got rows its id value starting
from "1001" to "5999"
I want to filter the rows that its first character is "2" or "3" or
whatever
the "2" or "3" ... come in a variable
what is the filtering code, please
Moses


*Lysander*

2005-11-11, 7:23 am

In article <AA8GZhr5FHA.1232@news-server>, mosesjhanna@hotmail.com=20
says...

> the "2" or "3" ... come in a variable
> what is the filtering code, please


I am no friend of using too many client-side filters, but you can do it=20
as well using a WHERE-clause in your query-statement, together with a=20
LIKE-clause.

As follows:
form.query1.sql =3D "select * from The_Table WHERE ID_field LIKE :id"
form.query1.params["id"] =3D ltrim(rtrim(form.entryfield1.value))+"%"
form.query1.requery()

In this case, your id would be given in "entryfield1" of the form.
The Placeholder "%" is needed for "unknown rest of the string".

So, entering "2" in the entryfield will show you all results with ids=20
2000 - 2999.
Entering "21" will show you all results with ids 2100 - 2199

Warning: Entering "2146" for example will not show you anything, because=20
there is not an additional character represented by the placeholder "%".



--=20
ciao,
Andr=E9
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