Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filter

Status
Not open for further replies.

filipe29

Programmer
Jan 14, 2006
23
PT
hi i have a simple adoquery and a filter like this:

if combo.text='Nome' then
dm.Qry_clientesP.Filter:='Nome like'+texto.Text

texto is a editbox

when i do that tells me that the arguments are of incorrect type or out of range or in conflit with the others.
 
You probably need quotes around texto.text.

Try
Code:
if combo.text='Nome' then
          dm.Qry_clientesP.Filter:='Nome like'+QuotedStr(texto.Text)

Andrew
Hampshire, UK
 

And a space after the LIKE.

Code:
                                   .--- here
                                   v
dm.Qry_clientesP.Filter:='Nome LIKE ' + QuotedStr(texto.Text)

If you are checking for equality, use 'Nome = ', it is better efficiency wise; if you are really needing LIKE, you need some wilcards too: "Nome LIKE Mar%" (to get Mario and María and Mary). Beware the wilcard character can change in different SQL engines.

buho (A).
 
The % doesn't work.How can i filter a integer and a string with searching just a little part of ??

I'm using adoquery with sql server
 
I don't use ADO but in the BDE the wild card for filters is an asterisk not the percent sign which is standard SQL.

Andrew
Hampshire, UK
 
I use the percent sign in my LIKE queries as well, BDE to an AS400 backend.
 
Check the server manual, or google for "my_server_name wildcard".

buho (A).
 
Have you fixed this?

If not, here's my suggestion:

if combo.text='Nome' then
dm.Qry_clientesP.Filter:=
'Upper(Nome) like '+quotedstr('%'+Uppercase(texto.Text)+'%');

 
...just to add to my last post..

I've got a feeling the 'UPPER' keyword may not work in a filter, if not, may have to build the SQL each time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top