Reputation: 25
I'm working on a program in MS Access, and I'm just trying to enter some data into a test table to see how it works. I can't for the life of me see what is wrong with the syntax.
I'm getting a 3134 error code.
Maybe there is a reserved word I'm using? All of the data are strings (even things that probably should be something else). I changed them to strings to try and figure out what the problem is).
CurrentDb.Execute " INSERT INTO TempReg " _
& "(Timestamp, LName, FName, Grade, InventoryNumber, SerialNumber, MacAddress, PaidIn, CheckNum) VALUES " _
& "('test', 'test2', 'test', 'test', 'test', 'test', 'test', 'test', 'test');"
Just for fun, when I run the following code it works fine. I don't see what is fundamentally different.
CurrentDb.Execute " INSERT INTO TestTable " _
& "(SampleText, MoreText) VALUES " _
& "('test', 'test2');"
Thank you!
Upvotes: 1
Views: 34
Reputation: 25272
TimeStamp
is a reserved word, as per https://support.office.com/en-us/article/learn-about-access-reserved-words-and-symbols-ae9d9ada-3255-4b12-91a9-f855bdd9c5a2
You should change that field name, or try putting the name within [brackets] in your statement.
Upvotes: 1
Reputation: 775
Try to put field names in square brackets:
CurrentDb.Execute "INSERT INTO TempReg " _
& "([Timestamp], [LName], [FName], [Grade], [InventoryNumber], [SerialNumber], [MacAddress], [PaidIn], [CheckNum]) VALUES " _
& "('test', 'test2', 'test', 'test', 'test', 'test', 'test', 'test', 'test');", dbFailOnError
Upvotes: 1