Subject: RE: How can I put an operator into a variable?
If you want to use Execute for this (i.e. you are interpreting the comparison as LotusScript) then there are several things you need to do:
You have to arrange for the string that you pass to Execute to contain an End statement which returns your result. Execute executes statements, not expressions.
Any literals need to be expressed using a syntax that the LotusScript language accepts. E.g. rather than Smith, your expression will have to include the characters “Smith” (in quotes) or use other quote characters {} or || so that LotusScript knows you aren’t referring to a variable named Smith, but the string “Smith”.
If you have a string literal that contains quotes (or whatever character you’re using as a close quote) then you must “escape” those quotes, e.g. Robert “Big Bob” Morlane would become “Robert ““Big Bob”” Morlane”.
Then, assuming your field is a string, you would have something like:
retval = Execute (" End " + Quote(doc.GetItemValue(FieldNM)(0)) & Operator1 & Quote(UName)
Where Quote is a custom function that uses Replace to change a string to a quoted literal.
Function Quote(Byval x As String) As String
Quote = {"} & Replace(x, {"}, {""}) & {"}
End Function
However, I suspect that what you’re doing here is going to be very inefficient. If you’re searching for documents that meet certain user-specified conditions, and if you have multiple conditions, then rather than loading each document into memory and calling Execute multiple times for each to see whether it meets the criteria, you will be much better off creating one formula language expression or full-text query that incorporates all your conditions, and then use that with the Search or FTSearch method to make the system find just the ones you want, with a single call. You will of course still need to put quotes around your string literals, though the exact formatting is different with these different techniques.