How Cope With Apostrophe in Variable?

D

David Habercom

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
 
S

SirPoonga

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

""
 
S

SirPoonga

Errr, or simplify to

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