>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.
Raj,
You've created multiple threads for basically the same question. Your previous threads already have good replies. ie: As Sergey said you don't need to build complex looking strings and do a macro substitution, directly execute your query. Trying to create a string first only serve to make it more complex. Repeating here what Sergey already said :
set ansi off
select * from projects ;
where proj = trim(thisform.combo1.value) ;
and contract = trim(thisform.combo2.value) ;
order by project_id into Cursor lcSource
Cetin