Replacing Quotes (1 Viewer)

EndersG

Registered User.
Local time
Today, 10:05
Joined
Feb 18, 2000
Messages
84
I getting hung up on using the FindFirst method when I attempt to located a name with quotes. For example:

Dim str as String
str = "O'Reilly"

rs.FindFirst "[Customer] = '" & str & "'"

I tried:

rs.FindFirst "[Customer] = '" & Replace(str,"'","''") & "'"

but it doesn't work.

It keeps returning a syntax error despite me using the Replace function. What am I doing wrong? Can anyone help?

Thanks.
 

pono1

Registered User.
Local time
Today, 02:05
Joined
Jun 23, 2002
Messages
1,186
Try something like this...

Code:
Dim str As String
str = Replace("O'Reilly", "'", "''")
Me.RecordsetClone.FindFirst "[Customer] = " & "'" & str & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

Regards,
Tim
 

EndersG

Registered User.
Local time
Today, 10:05
Joined
Feb 18, 2000
Messages
84
Replace Function

Thansk pono1. Worked like a charm.
 

Users who are viewing this thread

Top Bottom