>Hello,
>
>I am using Visual FoxPro 6.0 and I am making a search-form. On the form there are 8 textboxes, 1 button and a grid. If I fill in the textboxes and push the search-button a select-command is being executed and the results are put in a cursor with the following command:
>
>SELECT <...> FROM <...> INTO CURSOR cursorname WHERE <...>
>
>The grid is then using the cursor to show the results.
>
>I am using one select-command to search in the tables for the values in all the textboxes. The problem is that if I leave a textbox empty, the select-command is searching for empty fields. Is it possible not to search for empty textboxes with one select-command?
>
>Thank you for your time.
A simple way of doing that is building a generic SQL. It would be fast too if fields are indexed. Build your SQL like this :
cSQL = "select ... from "+;
"FROM <...> INTO CURSOR cursorname "+;
"WHERE myVal1 = trim(thisform.textbox1.value) "+;
" and myVal2 between "+;
"iif(empty(thisform.textbox2.value),nMinVal,thisform.textbox2.value) "+;
"and iif(empty(thisform.textbox2.value),nMaxVal,thisform.textbox2.value) "+;
" and myVal3 between "+;
"iif(empty(thisform.textbox3.value),{},thisform.textbox3.value) "+;
"and iif(empty(thisform.textbox3.value),date(),thisform.textbox3.value) "+;
....
thisform.searchgrid.recordsource = cSQL
thisform.searchgrid.recordsourcetype = SQL
thisform.searchgrid.refresh
Cetin