Solved

ADO Find Method

Posted on 2000-05-11
9
140 Views
Last Modified: 2010-05-02
This does not work when the string contains a single quote.  Anyone one know a way around this?    



RstNewUserLookUp.Find ("UserID = " & "'" & strUserID & "'")
0
Comment
Question by:BBrian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 6

Expert Comment

by:setiawan
ID: 2802950
Hi Bbrian,

What about using chr(39) instead of single quotes.

RstNewUserLookUp.Find "UserID = " & chr(39) & strUserID & chr(39)

from MSDN CD :
The value in criteria may be a string, floating point number, or date. String values are delimited with single quotes (for example, "state = 'WA'"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#").

so it should be work.

  danny

0
 
LVL 6

Accepted Solution

by:
Marine earned 100 total points
ID: 2802992
is userID a string value ? If so then this.

RstNewUserLookUp.Find "USerID='" & Replace(strUserId,"'","''") & "'"
0
 

Author Comment

by:BBrian
ID: 2805572
Marine
Your solution seems to work.  But I'm not sure why.  So if

UserID = "O'Malley"
then function passes
'O''Malley'

How does the search function read this expression?  
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BBrian
ID: 2807871
setiawan
I Tried
RstNewUserLookUp.Find "UserID = " & chr(39) & strUserID & chr(39)

But it didn't work.
Has anybody else encounterd this problem
0
 

Author Comment

by:BBrian
ID: 2811821
Also I have found that this expression
fails if there is more than one "'"


RstNewUserLookUp.Find "USerID='" & Replace(strUserId,"'","''") & "'"
0
 

Author Comment

by:BBrian
ID: 2811824
Adjusted points from 50 to 100
0
 

Author Comment

by:BBrian
ID: 2812193
Hey Programmers!
I found an interesting article on this problem.
http://msdn.microsoft.com/library/partbook/accsybex/acsybex_chap6.htm#acsybex_topic10
0
 

Author Comment

by:BBrian
ID: 2812266
Thanks Marine!!
But if there is more than one "'"
it fails.  You can use "#" & struserid & "#"

But then you can't use pound signs and apostrophes together in a single
 



0
 
LVL 6

Expert Comment

by:Marine
ID: 2812497
Your Welcome. Thanks for the points.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question