View Full Version : Insert dones't work


JSL
12-19-2000, 10:34 AM
Dear Sir:

I have a push button in a form, whenever
user click this button under this event
I have VB code to insert a record into
a table like following :

Private Sub send_Click()

SQL = "INSERT INTO log (datetime, cmd, note) VALUES ('1998-12-31 23:59:59', '1111111', '2222222')"

End Sub

The function seem to work because I did not
get any err message but inside the table there is no any new record.

Why ? How ?

Thank in advance

jsl



[This message has been edited by JSL (edited 12-19-2000).]

Jack Cowley
12-19-2000, 12:10 PM
Try:

Private Sub send_Click()

Dim db As Database
Set db = CurrentDb

db.Execute "INSERT INTO log (datetime, cmd, note) VALUES ('1998-12-31 23:59:59', '1111111', '2222222')"

End Sub

Atomic Shrimp
12-19-2000, 12:38 PM
Or

Private Sub send_Click()

DoCmd.RunSQL "INSERT INTO log (datetime, cmd, note) VALUES ('1998-12-31 23:59:59', '1111111', '2222222')"

End Sub

Pat Hartman
12-19-2000, 03:45 PM
If datetime is defined as a date/time data type, it needs to be surrounded by pound signs (#) not single quotes ('). If cmd or note are numeric data types, they should not be surrounded by anything.