Access Form "INSERT INTO" not working

Let me preface this by first of all saying I haven't done much VB in several years. However, the current project I'm working on at work I'm having to create an application in Access using VBA. It's just a prototype so that management can see that the process will work, but I'm having trouble with one section. Essentially I have a form with one text box on it that when the user clicks the button it will add whatever the user typed in along with a time and date stamp into the Access database.

The current code I've just been testing with is:

CurrentDb.Execute "INSERT INTO Status ('empid', 'monitor_id') VALUES ('111111', 'test');"

whether I'm using just one field or the other or both fields, I'm consistently getting the error message:

Run-time error '3127': The INSERT INTO statement contains the following unknown field name: "empid". Make sure you have typed the name correctly and try the operation again.

I've gone through the help files and have two books sitting on my desk here and ran into several different things... one saying use an ADOX connection, another simply saying you should be able to do a "Dim varx as Database" and then call the execute function, but it's saying user type not defined.

At this point, I'm getting rather frustrated.. could anyone point me in the right direction as to how to insert the contents of a text box on an Access form into a table in the database without using the form navigation buttons at the bottom to create a new record Thanks!




Answer this question

Access Form "INSERT INTO" not working

  • Robert E Wilson

    Ok, found my error... apparently Access databases won't let you specify field names with quotes around them whereas some other database make you use quotes. *shrug*

  • Access Form "INSERT INTO" not working