View Full Version : Ask Variable and Contains


03-13-2005, 04:16 PM
Field = Salesmen
Ask Variable = WhatSalesmen

Salesmen is a character field with a length of 50,so we can input free text.

Rec #1 The field Salesmen contains "Joe, Bob, Jake, John"
Rec #2 The field Salesmen contains "Bob, Luke, Peter"
Rec #3 The field Salesmen contains "John, Paul"
The input to the ask variable = Bob

I would expect rec #1 and #2 to be found, but no records are being found.

I've tried contains(var"WhatSalesmen, Salesmen)but it did not work.

I've tried setting a new variable to equal the field salesmen, then compare the to variables, but that did not work.

Any help would be appreciated.

Thanks in advance.

Stan Mathews
03-13-2005, 04:44 PM
Well, when I read the documentation for contains() and see

"The target to examine, a character string containing words separated by space characters."

I don't think a string of names separated by commas is the same thing.

So you can either have the "input free text" enterers exclude the commas or you can do it for them with a form event rule or similar.

Stan Mathews
03-13-2005, 04:49 PM
I also think you have

contains(var"WhatSalesmen, Salesmen)

backwards. To search the field Salesman for the word in the ask variable

CONTAINS( Search_String as C or target, Find_Words as C or words to find)


but since your are only looking for one word you may want

$ (Substring Inclusion Operator)
Logical Result = Find_String as C $ Search_String as C

var"WhatSalesmen $ Salesmen

03-14-2005, 03:23 AM
I don't know if this makes a difference or not, but the filter I am attempting is on a subreport, of a set's report,with one to many links. The table that the report filters is a child table.

I have gotten the report to work to the extent it returns only one, or two, of the anticipated records, out of a possible 50 or more.

03-14-2005, 03:38 AM
I think I may have stumbled on a solution, but not sure how to correct it. It lies in the linking fields.

The linking field in the parent table is Salesman, where I've given each salesman a unique name, as opposed to using the salesman's first name.

The child table has a salesmen field, where the unique salesman's name is entered.

Naturally, where only 1 name is entered, the record is found, but when more than 1 name it is not found. It does not matter where there names are separated by spaces, a comma, or all run together.

So, it would seem, I must devise a way to connect the linking fields, but can't figure out how.

G Gabriel
03-14-2005, 02:41 PM
""I would expect rec #1 and #2 to be found, but no records are being found. ""
You won't find BOB, but you will find "Bob,"
"bob," is seen by alpha as one word, the coma is read as part of the name !!!