Insert New Record

T

tiredoftrying

I need the code to insert a new record in a table that is in the same .mdb
database that my form is in, I want a command button that on click will
insert a record into a table called POINTS

The POINTS table has 2 fields called NAME_ID and SCORE - both are number
fields and for testing purposes I want bot to get a value of 1 inserted when
the record is created.
 
D

Dirk Goldgar

tiredoftrying said:
I need the code to insert a new record in a table that is in the same
.mdb database that my form is in, I want a command button that on
click will insert a record into a table called POINTS

The POINTS table has 2 fields called NAME_ID and SCORE - both are
number fields and for testing purposes I want bot to get a value of 1
inserted when the record is created.

Here's one way:

CurrentDb.Execute _
"INSERT INTO POINTS (NAME_ID, SCORE) " & _
"VALUES(1, 1)", _
dbFailOnError
 
T

tiredoftrying

very helpful - but one more question, using the code you provided what if I
wanted to use fields on my form that has the values in them to populate the
new record
 
Top