Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use the SELECT-command with empty values
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00149479
Message ID:
00149482
Views:
18
There are at least two ways to approach this. One is to build the select on the fly and just not include empty fields in the WHERE clause. The other is to use LIKE instead of =. For instance, your SELECT might look like this:
SELECT * ;
  FROM mytable ;
  WHERE Field1 LIKE m.Field1Val AND Field2 LIKE m.Field2Val AND ...
Then you could just make all of the m.FieldxVal equal to TRIM(value the user entered)+'%'. This would give you anything starting with the value entered and everything if the user entered nothing. This will only work with character data, of course.

>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform