removing charactes in a string from the right

  • Thread starter Thread starter Douglas J. Steele
  • Start date Start date
Hello,
I am building a SQL statement based on input from a text box on a form.

I am Splitting the textbox into separate words using the split function.

When I do the For loop to add the WHERE statement I have an extra 'OR' at
the end. How can I remove it?

Here is the code:

sqlCriteria = 'Like' (could also be 'Not Like')
sqlOperator = 'OR' (could also be 'AND')

x = Split(Me.txtFilterCriteria)
For i = 0 To UBound(x)
strSQl = strSQl & "(tblFeederLoads.[Notes #1]) " & sqlCriteria & "'*" & x(i)
& "*' " & sqlOperator
Next i


thanks
 
thanks

Douglas J. Steele said:
strSQl = Left$(strSQl, Len(strSQl) - 3) as a new line after the next i line.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Santiago Gomez said:
Hello,
I am building a SQL statement based on input from a text box on a form.

I am Splitting the textbox into separate words using the split function.

When I do the For loop to add the WHERE statement I have an extra 'OR' at
the end. How can I remove it?

Here is the code:

sqlCriteria = 'Like' (could also be 'Not Like')
sqlOperator = 'OR' (could also be 'AND')

x = Split(Me.txtFilterCriteria)
For i = 0 To UBound(x)
strSQl = strSQl & "(tblFeederLoads.[Notes #1]) " & sqlCriteria & "'*" & x(i)
& "*' " & sqlOperator
Next i


thanks
 
Back
Top