General information
Title:
Select query for dynamic search with if condition
I am trying to create a select query to search the table (dynamic search)
if i fill the project and contract text boxes it should search with both criteria, if i dont fill project then it should ignore project and then search only with contract, if i fill only project then it should search only with project and ignore the contract if completely.
the following i use in VB with multiple fields.
I want to use the same style query in VFP.
Can you please help me create it.
******************
ssql = "select * from projects"
If combo1.Text <> "" Then
wsql = " where proj = thisform.combo1.value"
EndIf
If combo2.Text <> "" Then
If wsql <> "" Then
wsql = wsql + " and " + " contract = thisform.combo2.value"
Else
wsql = " where contract = thisform.combo2.value"
EndIf
EndIf
osql = " order by project_id into Cursor lcSource"
ssql = ssql + wsql + osql
&ssql
************************
Thank you very much in advance.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only