>Hello all,
>My 'Select' statement returns all records when the key field is blank ie ""
>The table key field is character. set Exact is on. Vfp 5
>Any help?
>
>Samlpe code:
>SELECT RES_CODE, RES_NAME, RUNIT_CODE FROM RES_REC INTO ARRAY RECARRAY ;
>WHERE rec_no = alltrim(thisform.txtrecno.value)
A value of "" matches all records. It is not a bug. It basically states find all records where the rec_no starts with "". And all records start with nothings.
If you wish to search on only those fields that the user enters data in, then I would build a where clause using a CASE or IF statement.
lcWhere = ''
llAndFlag = .F.
IF NOT EMPTY(thisform.txtrecno.value)
lcWhere = 'rec_no = ' + alltrim(thisform.txtrecno.value)
llAndFlag = .T.
ENDIF
IF NOT EMPTY(some.other.field.value)
IF llAndFlag
lcWhere = 'AND some_other_field = ' + alltrim(some.other.field.value)
ELSE
llAndFlag = .T.
lcWhere = 'some_other_field = ' + alltrim(some.other.field.value)
ENDIF
ENDIF
Etc...
HTH
Bret Hobbs
"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope