How Cope With Apostrophe in Variable?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My VBA command line is

DoCmd.OpenReport strCoverLtr, , , "DonName =" & "'" & strDonorFilter & "'" &
""

It works perfectly until it gets to a donor named O'Neal. At that point
strDonorFilter causes a crash. Is there a trick for this?

Thanks
 
tempFilter= Replace(strDonorFilter, "'". "''")
DoCmd.OpenReport strCoverLtr, , , "DonName =" & "'" & tempFilter& "'" &

""
 
Errr, or simplify to

DoCmd.OpenReport strCoverLtr, , , "DonName =" & "'" &
replace(strDonorFilter, "'", "''") & "'" &
""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top