Solved

ADO Find Method

Posted on 2000-05-11
9
134 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

24 Experts available now in Live!

Get 1:1 Help Now