Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code to search a table for a value and return fieldname
Message
From
02/03/1999 17:43:21
Bob Lucas
The WordWare Agency
Alberta, Canada
 
 
To
02/03/1999 16:21:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00193342
Message ID:
00193367
Views:
13
>What would be a Code to search a table for a value and return the fieldname containing that value, (perhaps multiple fieldnames, perhaps multiple records)?


findval =
xtype = TYPE('findval')

SELECT mtable

GO TOP

SCAN
FOR i = 1 TO FCOUNT()
cfield = FIELD(i)

fieldval = EVALUATE(cfield)

IF TYPE('fieldval') = xtype
*-- check the value

IF !ISNULL(fieldval)
*-- assume we don't want a null value

IF fieldval == findval
ldone = .T.
EXIT
ENDIF

ENDIF
ENDIF
ENDFOR

IF ldone
? cfield
? fieldval
EXIT
ENDIF

ENDSCAN
Previous
Reply
Map
View

Click here to load this message in the networking platform