BBrian
asked on
ADO Find Method
This does not work when the string contains a single quote. Anyone one know a way around this?
RstNewUserLookUp.Find ("UserID = " & "'" & strUserID & "'")
RstNewUserLookUp.Find ("UserID = " & "'" & strUserID & "'")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
ASKER
setiawan
I Tried
RstNewUserLookUp.Find "UserID = " & chr(39) & strUserID & chr(39)
But it didn't work.
Has anybody else encounterd this problem
I Tried
RstNewUserLookUp.Find "UserID = " & chr(39) & strUserID & chr(39)
But it didn't work.
Has anybody else encounterd this problem
ASKER
Also I have found that this expression
fails if there is more than one "'"
RstNewUserLookUp.Find "USerID='" & Replace(strUserId,"'","''" ) & "'"
fails if there is more than one "'"
RstNewUserLookUp.Find "USerID='" & Replace(strUserId,"'","''"
ASKER
Adjusted points from 50 to 100
ASKER
Hey Programmers!
I found an interesting article on this problem.
http://msdn.microsoft.com/library/partbook/accsybex/acsybex_chap6.htm#acsybex_topic10
I found an interesting article on this problem.
http://msdn.microsoft.com/library/partbook/accsybex/acsybex_chap6.htm#acsybex_topic10
ASKER
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
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
Your Welcome. Thanks for the points.
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