Solved

ADO Find Method

Posted on 2000-05-11
9
135 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now