edit command docmd.FindRecord in access vba

Hi,

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 " ' ?
drtopservAsked:
Who is Participating?
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)), "'", "''")

or:

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

should do.

/gustav
0
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.
0
Gustav BrockCIOCommented:
Maybe you need this:

    DoCmd.FindRecord strProjectName, acEntire, , , , acAll

/gustav
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

    Go"s'E"y"

and

    DoCmd.FindRecord MySearch

found the record right away.

/gustav
0
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:{
0
Gustav BrockCIOCommented:
No, sorry, I just used an existing form and table, created one record with the wording, and called the command as shown.

/gustav
0
drtopservAuthor Commented:
this is the whole code:

Private Sub cboFindProjectName_AfterUpdate()
Stop

Dim strProjectName As String

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

    DoCmd.FindRecord strProjectName
   
 Me.cboFindProjectNumber = txtProjectNumber.Value

RetangleBox2.Visible = False

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

    strProjectName = Me!cboFindProjectName
    DoCmd.FindRecord strProjectName

/gustav
0
drtopservAuthor Commented:
I make now a query grid.
in the criteria instead of :
Go"s'E"y"

i put :

"Go""s''E""y"""
result -> Nothing!
0
drtopservAuthor Commented:
this :

"Go""s'E""y"""

in a grid query works!

does this help maybe?
0
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))

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

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

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

or:

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

/gustav
0
drtopservAuthor Commented:
not working:{
0
Dale FyeCommented:
@drtopserv,

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) & "]")
0

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 FyeCommented:
This method should treat the quote and single quotes as literal values
0
drtopservAuthor Commented:
I love you man!!!
IT WORKS!!!!
0
Jeffrey CoachmanMIS LiasonCommented:
Can we ask why that rather odd text string exists?

What type of data is that/this?
0
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.
0
Jeffrey CoachmanMIS LiasonCommented:
thanks
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.