From: Dirk Goldgar on 8 Mar 2010 14:06 "Ann" <Ann(a)discussions.microsoft.com> wrote in message news:CDC5DB6A-D111-4E25-AB26-ECF8EEF65639(a)microsoft.com... > Thank you that worked great. I had Chr(39) in the code but changed it to > the > double quotes you suggested and everything worked. You can use Chr(34) to avoid having to double up the quotes: stCriteria = _ "([txtCourseTitle] = " & _ Chr(34) & Me.txtCourseTitle & Chr(34) & _ " And [txtVendorName] = " & _ Chr(34) & Me.txtVendorName & Chr(34) & ")" Of course, you do still have a risk if the values you're embedding have double-quotes in them. But that's much less likely than single-quotes/apostrophes, and you probably know if you need to allow for that. If you do, you have to do something like this: Const Q As String = """" Const QQ As String = Q & Q stCriteria = _ "([txtCourseTitle] = " & _ Q & Replace(Me.txtCourseTitle, Q, QQ) & Q & _ " And [txtVendorName] = " & _ Q & Replace(Me.txtVendorName, Q, QQ) & Q & ")" -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |