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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter (TTable) - Partial String compare

Status
Not open for further replies.

GlynW

Programmer
Feb 14, 2001
22
0
0
GB
You'll have to forgive me, I new to Delphi, but have been a programmer in other languages for years.

I am using the filter property to filter the records depending on text entered into an edit box. The problem I am having is as follows:

I can only get results for strings that have a partial string at the beginning of a string. I want to get any of the following results for the following text:

edit box text : box

required results in the name field:

The box
box company
boxes and bits

The code I have will only return the last two results..

strSearch := 'NAME = ' + CHR(39) + TRIM(edit1.text) + '*' + cHR(39)

I have tried adding a second * wildcard at the front but this returns nothing... I have also tried the '%' either side which don't seem to work in the table filter.

I would be thankfull for any help that you could give me
 
Have you made sure the case is the same and using the LIKE keyword
eg.
myfilter := 'UPPER(name) LIKE ''*'''+UpperCase(Edit1.text)+''*''';

I may have the number of apostrophies wrong here.

hope that helps

lou
 
I tried what you said, and the program compiles and runs but when the filter is activated it comes up with the message 'Operation Not Applicable'.

It doesn't seem to like the LIKE command inside the filter (no pun intended!)

Is there something else going wrong?
 
hi Glyn

What DB are you using? It may be that the 'UPPER' is wrong and could have a different name, eg ToUpper or UpperCase. Try experimenting with your query in SQLExplorer. IE, in the WHERE clause use LIKE and see if you get the required results. If the 'upper' is wrong and you get it running, then try with your '%' too. I think if the query runs in SQLExplorer then the condition should run in the Filter property.

lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top