[CODE]
Public Function MySQL_EscapeVarValue(ByRef xValue As Variant, Optional ByVal xRaiseError As Boolean = True, Optional ByVal EscapeForLike As Boolean = False) As String
  Dim xDate1 As Date
  Dim xChar1 As String

  Select Case VarType(xValue)
    Case VbVarType.vbDate
      xDate1 = xValue
      xChar1 = Right("000" + CStr(Year(xDate1)), 4&) + _
               "-" + _
               Right("0" + CStr(Month(xDate1)), 2&) + _
               "-" + _
               Right("0" + CStr(Day(xDate1)), 2&) + _
               " " + _
               Right("00" + CStr(Hour(xDate1)), 2&) + _
               ":" + _
               Right("0" + CStr(Minute(xDate1)), 2&) + _
               ":" + _
               Right("0" + CStr(Second(xDate1)), 2&)
      MySQL_EscapeVarValue = MySQL_EscapeValue(xChar1, EscapeForLike)
    Case VbVarType.vbBoolean
      MySQL_EscapeVarValue = CStr(-CLng(xValue))
    Case VbVarType.vbString
      MySQL_EscapeVarValue = MySQL_EscapeValue(xValue, EscapeForLike)
    Case VbVarType.vbError, _
         VbVarType.vbArray, _
         VbVarType.vbDataObject, _
         VbVarType.vbObject, _
         VbVarType.vbUserDefinedType
      If xRaiseError Then Error 13
    Case Else
      MySQL_EscapeVarValue = Trim(Str(xValue))
    End Select
  End Function