Question

I am using Locate with multiple fields and sometimes I am getting an "Incorrect number of search fields" error and have tracked it down to the data.

tbl.Locate('LName;FName;Stuff',
  VarArrayOf([LName+','+FName','+Stuff]),[loCaseInsensitive]);

Sometimes it worked and sometimes it did not and I traced it down to a Comma in the Stuff if it included a Comma in the text.

Stuff = "My dog is gray" would work.

Stuff = "I am at work, but not happy" would not. That extra Comma made it look like four data fields.

Do I have to Parse every string of incoming data for Commas and if any found replace them with what for the Locate to work? The included Comma version will have been stored without Parsing or modifying as I have no idea what they may have entered. "I am at work, but not happy" is a valid input by the user.

Thanks.

Was it helpful?

Solution

Do not concatenate all the search values into a single string. Instead, place them as distinct items in the array, just like the example in the documentation. That is, don't include the commas in the string:

tbl.Locate('LName;FName;Stuff',
  VarArrayOf([LName, FName, Stuff]), [loCaseInsensitive]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top