I added two new fields in our table "MTOStudy" & "OtherDesc" as Short Text data types. The other data types within the table are Number and Yes/No values.
However, adding the two columns and updating the table's respective form in Access I can't get to update the table after clicking the button.
Things I've confirmed:
- The button works, using the message box function.
- Variables line up with the table's.
- The code is identical to the working function excluding the addition of the "MTOStudy" and "OtherDesc" variables
- The Error Code I've been seeing is "Error number: 3078 ; The MS Access db engine cannot find the input table or query '128'. Make sure it exists and that its name is spelled correctly."
Debug's line: INSERT INTO tbl_MTO_vs_ETO ([Order], [Line], [MTO], [ETO], [DUP], [MTOStudy], [OtherDesc]) VALUES ( , , -1, 0, 0, "TEST ONE PUMP", "")
Here's the function below:
Private Sub btn_save_Click()
'On Error GoTo Err_Execute
If Me.Check_MTO = False And Me.Check_ETO = False And Me.Check_DUP = False Then
MsgBox ("Please select one of the classification options."), vbCritical
Else
Dim Append_SQL As String, tbl_target As String, _
target_fields As String, field_values As String, _
errLoop As Error
tbl_target = "tbl_MTO_vs_ETO"
target_fields = "([Order]," _
& " [Line]," _
& " [MTO]," _
& " [ETO]," _
& " [DUP]," _
& " [MTOStudy]," _
& " [OtherDesc])"
field_values = "(" _
& " " & Me.order & "," _
& " " & Me.line & "," _
& " " & Me.Check_MTO.Value & "," _
& " " & Me.Check_ETO.Value & "," _
& " " & Me.Check_DUP.Value & "," _
& " """ & Me.MTOStudy.Value & """," _
& " """ & Me.OtherDesc.Value & """)"
Call Check_MTO_Dropdown
Append_SQL = "INSERT INTO " & tbl_target & " " & target_fields & " VALUES " & field_values
CurrentDb.Execute Append_SQL
Debug.Print Append_SQL
On Error GoTo 0
Err_Execute:
If DBEngine.Errors.count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.description
Next errLoop
End If
'DoCmd.Close acForm, Me.name
'MsgBox ("Test"), vbOKOnly
End If
End Sub