Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching all fields in a database
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00012278
Message ID:
00012292
Views:
35
>I,ve made a search form for my little program but I.m having a bit of trouble getting the search form to search all the fields in a database, I can only get it to search one field. Can somebody help me?
>
>Thanks!
>Bill Clark
Hi bill, in the old days, that is in the 2.6/Windows I made
a function that takes every field in my 'screen' and check if
that field has a value, then the function returned to me with
a string that will let me do a SQL statements and voila!!!,
that was all, I improved the function to check for indexes and use
use those indexes. Now in 3.0/5.0 I am in the process to convert
that function, because we don't work with memvars no more,
and my function is completly dependant of memvars, that is,
m.MyFieldName when you issue SCATTER MEMVAR.
Anyways the idea is the next,

MyString=create_string('m.field1','m.field2',etc...)

IF .NOT. EMPTY(MyString)
SELECT * FROM my_table ;
WHERE &MyString ;
INTO CURSOR MyCursor
ELSE
=msgbox('Invalid Criteria',"",16)
RETURN
ENDIF
Example, if m.field1='Orange' and m.field is empty and
m.field3=4, create_string will return me this:

ALLTRIM(UPPER('Orange')) $ ALLTRIM(UPPER(field1)) ;
.AND. 4=field3

Note that it ignores field2, because is empty. In the function
you need to check for the type of the field, that is, if it
is character,numeric,memo, etc... to use the adecuated
conversions with ALLTRIM(),UPPER(),VAL(),etc... and construct
the string.
If you need further help, I'll be happy to help you, maybe
when I finish with the new version I'll post it here.
Hope this help.
Good Luck. :)
luisg@netrunner.net
Luis Guzman, MCP
"The only glory most of us have to hope for
is the glory of being normal." Katherine Fulleton Gerould
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform