edit command docmd.FindRecord in access vba


I have this code :
DoCmd.FindRecord Me!cboFindProjectName
that i put into a sub in a form .

Me!cboFindProjectName value is : Go"s'E"y",  

the -> ' and -> "  make a trouble in finding the record , how can i modify this line to bypass the " ' ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Depending on what you mean with "bypass", either:

    strProjectName = Replace(Replace(Me!cboFindProjectName, Chr(34), Chr(34) & Chr(34)), "'", "''")


    strProjectName = Replace(Replace(Me!cboFindProjectName, Chr(34), ""), "'", "")

should do.

drtopservAuthor Commented:
nope still not working .
I hope me able to explain the point.

I still need to search this field in the record :Go"s'E"y",  
replacing didn`t helped.
Gustav BrockCIOCommented:
Maybe you need this:

    DoCmd.FindRecord strProjectName, acEntire, , , , acAll

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

drtopservAuthor Commented:
still no luck:{
Gustav BrockCIOCommented:
Then it may be something else.
I've created a string, MySearch, which holds:



    DoCmd.FindRecord MySearch

found the record right away.

drtopservAuthor Commented:
very wierd, could plz send me your test demo file ?

me when i run your code , when there is no " or ' it does find it . otherwise no luck:{
Gustav BrockCIOCommented:
No, sorry, I just used an existing form and table, created one record with the wording, and called the command as shown.

drtopservAuthor Commented:
this is the whole code:

Private Sub cboFindProjectName_AfterUpdate()

Dim strProjectName As String

    'Moves to ProjectName text box and
    'finds the record of whatever name is selected in the combo box
    strProjectName = Replace(Replace(Me!cboFindProjectName, Chr(34), Chr(34) & Chr(34)), "'", "''")

    DoCmd.FindRecord strProjectName
 Me.cboFindProjectNumber = txtProjectNumber.Value

RetangleBox2.Visible = False

End sub
Gustav BrockCIOCommented:
I used this, similar to your original code:

    strProjectName = Me!cboFindProjectName
    DoCmd.FindRecord strProjectName

drtopservAuthor Commented:
I make now a query grid.
in the criteria instead of :

i put :

result -> Nothing!
drtopservAuthor Commented:
this :


in a grid query works!

does this help maybe?
Gustav BrockCIOCommented:
Not really, because it's different when you type in a string.
However, given your result, this might work:

    strProjectName = Replace(Me!cboFindProjectName, Chr(34), Chr(34) & Chr(34))

drtopservAuthor Commented:
I try it .
well if i put : Go's   ->Found
if i put : Go"s ->Not found

the problem with -> "
Gustav BrockCIOCommented:
Then perhaps this will do:

    strProjectName = Replace(Me!cboFindProjectName, Chr(34), "'" & Chr(34) & "'")


    strProjectName = Replace(Me!cboFindProjectName, Chr(34), Chr(34) & Chr(34) & Chr(34))

drtopservAuthor Commented:
not working:{
Dale FyeOwner, Developing Solutions LLCCommented:

in your second example above, is that a quote (") or two single quotes ('')?  The problem with doubling single quotes is that they get interpreted as an a single embedded quote.

you might want do try something like:

strFind = Replace(Replace(Me!cboFindProjectName, Chr(34), "[" & Chr(34) & "]"), chr(39), "[" & chr(39) & "]")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCCommented:
This method should treat the quote and single quotes as literal values
drtopservAuthor Commented:
I love you man!!!
Jeffrey CoachmanMIS LiasonCommented:
Can we ask why that rather odd text string exists?

What type of data is that/this?
drtopservAuthor Commented:
Oh yea,
Well I wanted to let user type a name of a project without limit him in chars etc..

then I`ll have a combobox let the user choose from the name of the project , which will contain ofcourse the quata`s types.
Jeffrey CoachmanMIS LiasonCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.