Single Quote, double quote - error and apostrophe

Experts, I have a report with a field that has a double click event.  I have noticed that I get an error if within txtDeliverable there is an apostrophe.  
Example:
txtDeliverable:
"Pay each invoice within 15 days of Interconnecting Party's receipt thereof"
                                                                                                             ^^^^apostrophe causes error on double click below

I had to run an update query to remove the apostrophe.  After I did the update then the double click event works.  
How to fix this?   Does the double click event need to be adjusted?  

Private Sub txtDeliverable_DblClick(Cancel As Integer)

        DoCmd.OpenForm "frmCovenantHistory", , , "[Deliverable]= '" & Me!txtDeliverable & "'"

End Sub
pdvsaProject financeAsked:
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.

GozrehCommented:
You can use the replace function to replace one apostrophe to two ''
DoCmd.OpenForm "frmCovenantHistory", , , "Replace([Deliverable],"'","''")= '" & Replace(Me!txtDeliverable,"'","''") & "'"
0
Rey Obrero (Capricorn1)Commented:
try this

 DoCmd.OpenForm "frmCovenantHistory", , , "[Deliverable]= " & chr(34) &  Me!txtDeliverable & chr(34)
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
pdvsaProject financeAuthor Commented:
Gozreh:  is there an extra apostrophe?  I get a syntax error at the ^^^
DoCmd.OpenForm "frmCovenantHistory", , , "Replace([Deliverable]," '"
                                                                                                                           ^^^

Rey:  txtDeliverable is a long line of text (its an import from excel).  I tried the chr(34) method as prescribed and while I don't get an error, the form that opens is blank and it shouldn't be.
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.

Rey Obrero (Capricorn1)Commented:
< txtDeliverable is a long line of text (its an import from excel). >
why not use an id or record id field as field in the Where clause???

and instead of using bang (!) use dot (.) in Me!txtDeliverable, i.e., Me.txtDeliverable
0
mbizupCommented:
The syntax in Reys comment is correct.  However, The command you're trying to run is looking for an *exact* match between Deliverable and  txtDeliverable.    If you are seeing no records on the form, it means that there are no exact matches.

-->> txtDeliverable is a long line of text

Generally exact match criteria is not used for lengthy text fields...

Perhaps try using LIKE:  

 DoCmd.OpenForm "frmCovenantHistory", , , "[Deliverable] LIKE " & chr(34) & "*" &  Me!txtDeliverable & "*" &  chr(34)

Open in new window

0
pdvsaProject financeAuthor Commented:
I can not use an ID because the records are duplicates for all intensive purposes and I am opening up all the occurrences and not just 1 record, which is what I would be doing if I used an ID.
0
pdvsaProject financeAuthor Commented:
It is correct.  I had a typo.  Sorry.

thank you.
0
GozrehCommented:
Try this
DoCmd.OpenForm "frmCovenantHistory", , , "[Deliverable]='" & Replace(Me!txtDeliverable,"'","''") & "'"
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.