[CODE]
Public Function MySQL_EscapeValue(ByVal xString As String, Optional ByVal EscapeForLike As Boolean = False) As String
  xString = "'" + Replace(Replace(xString, "'", "''"), "\", "\\") + "'"
  xString = Replace(Replace(Replace(xString, vbCr, "\r"), vbLf, "\n"), vbTab, "\t")
  xString = Replace(Replace(Replace(xString, vbNullChar, "\0"), Chr(7), "\b"), Chr(26), "\Z")
  If EscapeForLike Then
    xString = Replace(Replace(xString, "_", "\_"), "%", "\%")
    End If
  MySQL_EscapeValue = xString
  End Function