This is from a SAVE RECORD button:
I printed strSql using debug.print:
It does not work in VBA, it does not work in SQL in a query design view; INSERT SYNTAX ERROR.
But I can insert 31 and b manually in the database and I can insert 31 and b using a continuous form.
SpecID is long (links to autonumber in another table), Value is text.
I'm stumped. I copied that insert statement from another routine that works without problems.
Robert
Code:
Private Sub cmdSaveNewValue_Click()
10 Dim db As Database
20 Dim strSql As String
' Add new tblValues entry for New Value textbox.
30 Set db = CurrentDb
40 strSql = "INSERT INTO tblValues (SpecID, Value) VALUES (" & _
txtKey & ", '" & txtNewValue & "');"
50 db.Execute (strSql), dbFailOnError
60 db.Close
70 Me.Requery
80 cmdCancelNewValue_Click
End Sub
I printed strSql using debug.print:
Code:
INSERT INTO tblValues (SpecID, Value) VALUES (31, 'b');
It does not work in VBA, it does not work in SQL in a query design view; INSERT SYNTAX ERROR.
But I can insert 31 and b manually in the database and I can insert 31 and b using a continuous form.
SpecID is long (links to autonumber in another table), Value is text.
I'm stumped. I copied that insert statement from another routine that works without problems.
Robert