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

Case insensitive

Status
Not open for further replies.

apffal

Technical User
Apr 10, 2004
97
PT
I've defined the search value with the expression :
cValue = ALLTRIM(thisform.Text1.Value)
or
cValue = [']+ALLTRIM(thisform.Text1.Value)+[']

How can I modify it, to get case insensitive results ?
Thanks.
 
small typeo in Marcias example above, should still be understandable, but in case it isn't...

LOCATE FOR LOWER(ALLTRIM(SomeField)) == cValue

...there are also certain types of string search functions in VFP that are case-insensitive, such as ATC().

boyd.gif

SweetPotato Software Website
My Blog
 
So, how to use it with this code ?

cValue1 = ALLTRIM(thisform.Text1.Value)
lcField1 = thisform.cbo1.Value
SET FILTER TO cValue1 $ &lcField1
 
Code:
cValue1 = ALLTRIM(thisform.Text1.Value)
lcField1 = thisform.cbo1.Value

*!* Evaluate is better and faster than & (A.K.A "macro substitution")
Set Filter to lower(cValue1) $ Lower(Evaluate(lcField1)) IN "MyTable"
GO TOP IN "MyTable" && Ensures that the filter is enforced on the table

*!* Here's another way to do it
Select "MyTable"
Set Filter to ATC(cValue1, Evaluate(lcField1)) > 0
LOCATE && is faster than Go Top, but you need to have MyTable selected first

boyd.gif

SweetPotato Software Website
My Blog
 
Thanks !
But always gives me a syntax error on the line
Set Filter to lower(cValue1) $ Lower(Evaluate(lcField1)) IN "MyTable"
And if I delete the expression "IN my table", I only get the first record in search results.
I'm using FoxPro 6.0 and that is my complete code

IF !EMPTY(thisform.Text1.Value)

thisform.Texto1.visible = .T.

LOCAL lcField
Public cValue1

IF !EMPTY(thisform.Text2.Value)

lcWHERE = ""
cValue1 = [']+ ALLTRIM(thisform.Text1.Value) +[']
cValue2 = [']+ ALLTRIM(thisform.Text2.Value) +[']
cValue3 = [']+ ALLTRIM(thisform.Text3.Value) +[']
lcField1 = thisform.cbo1.Value
lcField2 = thisform.cbo2.Value
lcField3 = thisform.cbo3.Value

DO CASE
CASE THISFORM.opt.Value = 0
lcOperand = ""
CASE THISFORM.opt.Value = 1
lcOperand = "AND"
CASE THISFORM.opt.Value = 2
lcOperand = "OR"
ENDCASE

IF !EMPTY(thisform.Text3.Value)
lcWHERE = lcOperand + " " + cValue3 + " " + ;
"$" + " " + lcField3

lcWHERE = lcOperand + " " + cValue2 + " " + ;
"$" + " " + lcField2 + " " + lcWHERE

lcWHERE = cValue1 + " " + "$" + " ";
+ lcField1 + " " + lcWHERE
ENDIF

IF EMPTY(thisform.Text3.Value)
lcWHERE = lcOperand + " " + cValue2 + " " + ;
"$" + " " + lcField2

lcWHERE = cValue1 + " " + "$" + " ";
+ lcField1 + " " + lcWHERE
ENDIF

SET FILTER TO &lcWHERE

ELSE

cValue1 = ALLTRIM(thisform.Text1.Value)
lcField1 = thisform.cbo1.Value

SET FILTER TO cValue1 $ &lcField1

ENDIF

IF NOT EOF()
SKIP
ELSE
GO TOP
ENDIF
THISFORM.Refresh

COUNT TO X
GO TOP

ENDIF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top