Hi,
I have a database with one Table and one Form.
The table "Table1" fields: ID (AutoNumber), Date (Date/Time), Mark (Number)
In Form "Form1" is a button. When I press the button I want to add a new record in table "Table1" with these values: "26-Aug-2009" and "21" for Date and Mark.
Currently I have this code for onClick event:
Private Sub Command2_Click()
Dim strSQL1 As String
strSQL1 = "insert into Table1 (Date, Mark) Values ('26-Aug-2009', '22')"
DoCmd.RunSQL strSQL1
End Sub
But I get an error: "Syntax error in INSERT INTO statement". Why ? Because of field ID which is AutoNumber type ?
I have a database with one Table and one Form.
The table "Table1" fields: ID (AutoNumber), Date (Date/Time), Mark (Number)
In Form "Form1" is a button. When I press the button I want to add a new record in table "Table1" with these values: "26-Aug-2009" and "21" for Date and Mark.
Currently I have this code for onClick event:
Private Sub Command2_Click()
Dim strSQL1 As String
strSQL1 = "insert into Table1 (Date, Mark) Values ('26-Aug-2009', '22')"
DoCmd.RunSQL strSQL1
End Sub
But I get an error: "Syntax error in INSERT INTO statement". Why ? Because of field ID which is AutoNumber type ?
Last edited: