I have a button on a form that runs a query and displays the results in another form. The query looks for occurances of a particular string in one field of a table. It uses the data from one field (DN is the field name) displayed on the form. I use a ~ variable in the query for this. The field content is a text string which can be several words and can include puncutation characters. I ran into an issue with reserved words at the begining of the string and had to add
SearchVariable = "\""+ DN
to avoid problems (like the first word of DN being Unique).
But I recently added a record where the contents of DN begins with a word in double quotes. I checked for the quotes at the beginning and I can make the changes for that. But I had trouble when there was a secord quote in the string. I've tried breakapart and inserting a \ before the quotes and then reassembling the string, but either I'm doing something wrong or this isn't the right approach.
Here are examples of various values for DN
1. Miller's Opportunity Knocks Twice
2. Unique Opportunity
3. "In The Know
4. "In" The Know
For my query to work
1. SearchVariable = DN
2. SearchVariable = "\"" + DN
3. SearchVariable = "\"\\" + DN
4. ????
What can I do to get #4 to work? I hope I've explained this well. The query error messages are not at all helpful!
Lynn
SearchVariable = "\""+ DN
to avoid problems (like the first word of DN being Unique).
But I recently added a record where the contents of DN begins with a word in double quotes. I checked for the quotes at the beginning and I can make the changes for that. But I had trouble when there was a secord quote in the string. I've tried breakapart and inserting a \ before the quotes and then reassembling the string, but either I'm doing something wrong or this isn't the right approach.
Here are examples of various values for DN
1. Miller's Opportunity Knocks Twice
2. Unique Opportunity
3. "In The Know
4. "In" The Know
For my query to work
1. SearchVariable = DN
2. SearchVariable = "\"" + DN
3. SearchVariable = "\"\\" + DN
4. ????
What can I do to get #4 to work? I hope I've explained this well. The query error messages are not at all helpful!
Lynn