Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data to Query

Status
Not open for further replies.

LWB2005

Technical User
Jan 26, 2005
14
0
0
US
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
 
Does SearchVariable="in@@the know" work?

Or do you have to ONLY have ONE record returned, and it must match absolutely?

Tony McGuire
"It's not about having enough time. It's about priorities.
 
Tony,

It does need to be an exact match.

Lynn
 
OK.

Well, I have no idea how to search for text embedded in quotes.

Hopefully someone who allows such an animal, and needs to search it, will chime in.

Tony McGuire
"It's not about having enough time. It's about priorities.
 
I played around with this a bit.
The below gave me the record containing

=== This "is only" one ====

Code:
var
qbe     query
stQbe   string
endvar

stQbe="This \\\"is only\\\" one"


qbe=Query

quotesLocator.db | myString             |
                 | CheckPlus ~stQbe     |

EndQuery
qbe.executeqbe("quotesAnswer.db")

Tony McGuire
"It's not about having enough time. It's about priorities.
 
Tony,

Thanks. I will give it a try tonight.

Lynn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top