Create Interactive Search

Here is an example source code for interactive search in a table or grid. When typing words on textSearch then the result will be displayed on gridResult directly, and the description of the search results will be shown by labelResult .


TextSeacrh.InteractiveChange

xfilter=UPPER(ALLTRIM(THIS.Value))
 
Select * from cursor1 WHERE LIKE('*&xfilter*',upper(nm_brg)) into cursor cursor2
*? _TALLY
IF _TALLY=0
   thisform.GridResult.recordsource =""
   thisform.setGrid1
   GO TOP
   ELSE
   
   thisform.GridResult.recordsource ="cursor2"
   thisform.setGrid1
   GO TOP
   

   ENDIF
       
IF EMPTY(THIS.Value)
   THISFORM.LabelResult.visible= .F.
   ELSE
   THISFORM.
LabelResult.visible= .T.
IF _tally=0
  
THISFORM.LabelResult.Caption="No Data"   
   ELSE 
 
  THISFORM.LabelResult.Caption="Found "+ALLTRIM(STR(_tally))+" data"
   ENDIF
   ENDIF

thisform.setGrid1

thisform.gridResult.ColumnCount=2
thisform.gridResult.ReadOnly= .T.

thisform.gridResult.column1.ControlSource="alltrim(STR(id))"
thisform.gridResult.column2.ControlSource="alltrim(name_pd)"

0 Response to "Create Interactive Search"

Post a Comment

wdcfawqafwef