-1

Not sure what is causing the error.

CurrentDb.Execute "UPDATE dbo_RootCause SET Part = '" & Me.cboPart & "', Qty = '" & Me.cboQTY & "', Code = '" & Me.cboCode & "', Reason = '" & Me.txtReason & "', RootCause = '" & Me.txtRootCause & "', CorrectiveAction = '" & Me.txtCorrectiveAction & "', CAdate = '" & Me.txtCAdate & "', CA_Comp_By = '" & Me.txtCA_Comp_By & "', ReturnInv = '" & Me.cboReturnInv & "', ReturnCust = '" & Me.cboReturnCust & "', CustFollowUp = '" & Me.cboCustFollowUp & "' WHERE ListItems = " & Me.txtListItems & "", dbSeeChanges
Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45
  • 1
    start debugging: put your query into a string so you can capture the entire string you're building, and look for syntax errors. you're vulnerable to [sql injection attacks](http://bobby-tables.com) – Marc B Dec 14 '15 at 19:16
  • Stop concatenating SQL statements from user input. Use parameterized queries. In addition to protecting you from SQL injection, it removes the need for all of the repeated quotes, mistakes in data type conversions, repeated single/double quote combinations, and makes your code 1000x easier to read and maintain. – Ken White Dec 14 '15 at 19:20
  • [How to debug dynamic SQL in VBA](http://stackoverflow.com/a/1099570/3820271) . The end. – Andre Dec 14 '15 at 19:36

1 Answers1

0

You need format your date value as a valid string expression, and numbers are not strings. See examples:

CurrentDb.Execute "UPDATE dbo_RootCause SET Part = '" & Me.cboPart & "', Qty = " & Str(Me.cboQTY) & ", Code = '" & Me.cboCode & "', Reason = '" & Me.txtReason & "', RootCause = '" & Me.txtRootCause & "', CorrectiveAction = '" & Me.txtCorrectiveAction & "', CAdate = #" & Format(Me.txtCAdate, "yyyy\/mm\/dd") & "#, CA_Comp_By = '" & Me.txtCA_Comp_By & "', ReturnInv = '" & Me.cboReturnInv & "', ReturnCust = '" & Me.cboReturnCust & "', CustFollowUp = '" & Me.cboCustFollowUp & "' WHERE ListItems = " & Me.txtListItems & "", dbSeeChanges
Gustav
  • 53,498
  • 7
  • 29
  • 55