Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select query for dynamic search with if condition
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00906123
Message ID:
00906180
Views:
13
Hello Raj,

Try this

IF NOT EMPTY(thisform.txtProject.value) THEN
lcCondition1 = 'PROJECT = ' + CHR(34) + thisform.txtProject.value + CHR(34)
ENDIF

IF NOT EMPTY(thisform.txtCondition.value) THEN
lcCondition2 = 'CONTACT = ' + CHR(34) + thisform.txtCondition.value + CHR(34)
ENDIF

lcSQL = 'SELECT * from TABLE_NAME' + ;
IIF(not EMPTY(lcCondition1), ' WHERE ' + lcCondition1 + ;
IIF(not EMPTY(lcCondition2), ' AND ' + lcCondition2, SPACE(0)),;
IIF(not EMPTY(lcCondition2), ' WHERE ' + lcCondition2, SPACE(0)))

EXECSCRIPT(lcSQL)
Previous
Reply
Map
View

Click here to load this message in the networking platform