Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for WHERE Clause 1

Status
Not open for further replies.

bernie10

Technical User
Sep 13, 2004
219
US
Hello everyone,

I need to set the recordsource of a form by code. I do something like this:

Forms!frmSelectCase!sfrmEvaluation.Form.RecordSource = SQLSelectCase & "WHERE...;"

SQLSelectCase is a string which contains the select cause. I am having trouble getting the WHERE clause with the correct syntax.

If I was doing it in a query the WHERE clause would be:

WHERE (((qryEvaluation.ProblemDescription) Like Nz("*" & Forms!frmProblemDesc!txtKeyword1 & "*","*") And (qryEvaluation.ProblemDescription) Like Nz("*" & Forms!frmProblemDesc!txtKeyword2 & "*","*") And (qryEvaluation.ProblemDescription) Like Nz("*" & Forms!frmProblemDesc!txtKeyword3 & "*","*") And (qryEvaluation.ProblemDescription) Like Nz("*" & Forms!frmProblemDesc!txtKeyword4 & "*","*")));

but I know since I'm doing it with VB I need to do some different things with my single and double quotes to make it a valid string; I am not sure how to adjust the above WHERE clause where I can use it in my:

Forms!frmSelectCase!sfrmEvaluation.Form.RecordSource = SQLSelectCase & "WHERE...;"

statement. Could someone help? Thanks.

Collen
 
Forms!frmSelectCase!sfrmEvaluation.Form.RecordSource = SQLSelectCase & " WHERE " _
& "qryEvaluation.ProblemDescription Like '*" & Forms!frmProblemDesc!txtKeyword1 & "*' AND " _
& "qryEvaluation.ProblemDescription Like '*" & Forms!frmProblemDesc!txtKeyword2 & "*' AND " _
& "qryEvaluation.ProblemDescription Like '*" & Forms!frmProblemDesc!txtKeyword3 & "*' AND " _
& "qryEvaluation.ProblemDescription Like '*" & Forms!frmProblemDesc!txtKeyword4 & "*'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top