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
Solved

ADO Find Method

Posted on 2000-05-11
9
137 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

790 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