if LEN(ALLTRIM(thisform.text25.value)) >= 3 lcFormValue = trim( Thisform.text25.Value ) THISFORM.TEXT10.Value=lcFormValue WAIT for i=1 to 3 cAlias = ICASE(i=1,'mstr2010',i=2,'mstr2001','mstr2011') text to cSQL noshow pretext 15 TEXTMERGE SELECT no,img1 ,EXPBDATE,SDISC,STYPE,ansdisc,expbno from <<cAlias>> WHERE ATC( "{{lcFormValue}}", SDISC ) > 0 INTO cursor TAliascursor1 readwrite endtext &cSQL ************************************** thisform.Grid2.RecordSource=" TAliascursor1" IF i = 1 AND _Tally # 0 thisform.Grid2.RecordSource="TAliascursor1" thisform.grid2.visible=.t. thisform.grid2.enabled=.t. thisform.edit2.visible=.t. EXIT ENDIF IF i= 2 AND _Tally # 0 MESSAGEBOX("Found !!") thisform.Grid2.RecordSource="TAliascursor1" thisform.grid2.visible=.t. thisform.grid2.enabled=.t. thisform.edit2.visible=.t. EXIT endif IF i= 3 AND _Tally # 0 MESSAGEBOX("Found !!") thisform.Grid2.RecordSource="TAliascursor1" thisform.grid2.visible=.t. thisform.grid2.enabled=.t. thisform.edit2.visible=.t. EXIT ELSE thisform.grid2.visible=.f. thisform.grid2.enabled=.f. thisform.edit2.visible=.f. * MESSAGEBOX("Not Found") ENDIF NEXT ENDIF>I would additionally textmerge your "thisform.text25.value" in the SQL-Select. When the SQL processes it is expecting queries based on a table.field basis. When you throw at it a thisform.text25.value it sometimes gets confused... You might want to change like