Reputation: 1
Ok, I'm fairly new to Access. What I'm attempting to accomplish is using a command button to insert short text to a specific field within a table. So for example, in my Master form I'd like to have a command button, that when pushed, inserts the text "A1" into the Location field in my Master Inventory table. I tried accomplishing this by using the INSERT INTO statement, but I had no luck. Is this the best way to do it, or is there a simpler way? If it's the best way, then what am I doing wrong? Here is the code I used:
'add data to Master Inventory Table
CurrentDb.Execute "INSERT INTO MasterInventoryTable (Location) " & _
" VALUES ('A1') "
Upvotes: 0
Views: 6580
Reputation: 62831
I don't see anything wrong with your above syntax. What that attempts to do is insert a new row in your MasterInventoryTable table with the Location field set to "A1".
My guess is you have other columns in that table that are preventing the statement to run (what error are you receiving). Check your table design and see if any other fields are required.
Upvotes: 1