Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search a table for a string
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00811295
Message ID:
00811304
Views:
20
This message has been marked as a message which has helped to the initial question of the thread.
>Want to build a search function that would return the recno() of a row that contains a user defined string in any of the fields. Would like to make it generic so that I do not have to know the fields names. Can anyone point me in the right direction?
>
>Thanks
>
>Brenda

As a start:
lparameters lcString
if vartype(lcString) <> 'C'
   return -1
endif
local llFound, lnI, lnRec
for lnI = 1 to fcount()  && assuming table is open in the current workarea
    if inlist(type(field(lnI)), 'C', 'M')
       lcField = FIELD(lnI)
       locate for lower(lcString) $lower(&lcField)
       if not eof()
          llFound = .t.
          exit
       endif
    endif
endfor
lnRec = 0
if llFound
   lnRec = RecNo()
endif
return lnRec
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform