General information
Category:
Forms & Form designer
>My favorite thing in foxpro 2.6 was the ability to open a browse window the do a CTRL+F and find something in any viewable field in the browse
>
>My question is, is there any way to have a grid on a form then do a CTRL+F and find a value in any viewable field in the grid
Hi Stephen,
I have learned this code from Marcia Akins.
LPARAMETERS tcAlias, tuSearchVal, tlMatchWholeField
LOCAL laFields[1], lnFieldCnt, lnField, llMatchFound, luCompVal
*** Make sure passed alias is available
IF ! USED( tcAlias )
USE ( tcAlias ) IN 0
ENDIF
*** Get the field names
lnFieldCnt = AFIELDS( laFields, tcAlias )
SELECT ( tcAlias )
*** Scan the table
SCAN
*** look for a match in each field
FOR lnField = 1 TO lnFieldCnt
luCompVal = IIF( INLIST( VARTYPE( EVAL( lafields[ lnField, 1 ] ) ), 'C', 'M' ), ALLTRIM( EVAL ( laFields[ lnField, 1 ] ) ), EVAL ( laFields[ lnField, 1 ] ) )
llMatchFound = .F.
IF tlMatchWholeField
IF tuSearchVal == luCompVal
llMatchFound = .T.
EXIT
ENDIF
ELSE
IF INLIST( VARTYPE( EVAL( lafields[ lnField, 1 ] ) ), 'C', 'M' )
IF tuSearchVal $ luCompVal
llMatchFound = .T.
EXIT
ENDIF
ENDIF
ENDIF
ENDFOR
IF llMatchFound
EXIT
ENDIF
ENDSCAN
IF llMatchFound
MESSAGEBOX( 'Match found in field: '+laFields[ lnField, 1 ]+CHR(13)+ 'Record Number '+ALLTRIM( STR( RECNO( tcAlias) ) ) )
ENDIF
Cemal.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only