Easy! SearchString for View.FTSearch

As an Notes Admin pressed into Development service last year, there are still certain syntax rules with which I am not familiar and this one is especially maddening!! I just need to build a searchString$ for View.FTSearch. The string should be:

Form = “Machine” AND Salesman = oldsales

where Salesman is a field and oldsales is the value I’ve pulled from another field. It says in the Help if I want to include a " in a string, to double it. However, when I use…

searchString$ = {Form = ““Machine”” & Salesman = oldsales}

… my string ends up with 4 " around ‘Machine’!! I KNOW this has an easy solution, but I’ve been in the Forum/Help for 4 hours and no longer fear the admonishments I will probably receive for posting such a “simple” question—what am I not getting?!

Any help is most appreciated.

Subject: Easy! SearchString for View.FTSearch

If using curly braces to define a string, you do not need to double your double quotes. So…

searchString$ = {Form = “Machine” & Salesman = “} & oldsales & {”}

That is assuming that oldsales is a string and ought to be enclosed with double quotes in the search string.

Subject: RE: Easy! SearchString for View.FTSearch

I just noticed that your subject was for FTSearch rather than Search, but you had started to create what looked like a Search formula. With FTSearch, you need only to specify the values you are searching for without specifying the field - the entire document will be searched.

Subject: RE: Easy! SearchString for View.FTSearch

Jason/Cesar,Thanks so much for the quick responses! Cesar, I put in the code you posted and searchString$ now resolves to:

“Form=”“Machine”" & Salesman=““Bob Smith””" and I get the “Query is not understandable” error.

Just so I’m on the right page, this is what it SHOULD be, right?

“Form=“Machine” & Salesman=“Bob Smith””

Thanks!

Subject: RE: Easy! SearchString for View.FTSearch

Hi Mark,

Yes - I had previously posted another response saying that I noticed only in your subject line that you were trying to do an FTSearch while I had suggested the syntax for a db.Search.

Subject: RE: Easy! SearchString for View.FTSearch

Thanks, Cesar…

I saw your post after I responded. With your and Jason’s advice I know a lot more about this. Now I won’t need to spend 4 hrs next time!

Thanks again!

Subject: RE: Easy! SearchString for View.FTSearch

if this is an FTSearch, try the following instead:

searchString$ = {[FORM] CONTAINS “Machine” AND [SALESMAN] CONTAINS “} & oldsales & {”}

Subject: RE: Easy! SearchString for View.FTSearch

Thanks, Jason…

That worked like a charm!

Subject: Easy! SearchString for View.FTSearch

you only need to escape double quotes when they are within other double quotes, like so:searchString$ = “Form = ““Machine”” & Salesman = oldsales”

you can surround strings in lotusscript with ", |, or {}