I have a question about doing an INSERT INTO in a table with an autonumber field in the table. Do I need to fill that field somehow or will it automatically be filled when the record is created?
I am getting an error on the following code:
MessageOperator, MessageDate, MessageTime, MessageNumber are all fields in the MessageNumbers table.
I have tried the same sqlstatement with only one field and one value and while testing that, I tried it with and without the ' delimiter around the variable in the values section but still keep getting the "Syntax error in INSERT INTO statement" error.
Any thoughts?
I am getting an error on the following code:
Code:
strMessageOperator = Environ("UserName")
strMessageDate = Format(Date, "Short Date")
strMessageTime = Format(Now, "Long Time")
strMessageNumber = (DCount("MessageNumber", "MessageNumbers", "Month([MessageDate]) like Month(Now)") + 1)
strSqlStatement = "INSERT INTO messagenumbers (MessageOperator, MessageDate, MessageTime, MessageNumber) Value ('" & _
strMessageOperator & "',#" & strMessageDate & "#,#" & strMessageTime & "#,'" & strMessageNumber & "')"
DoCmd.RunSQL strSqlStatement
MessageOperator, MessageDate, MessageTime, MessageNumber are all fields in the MessageNumbers table.
I have tried the same sqlstatement with only one field and one value and while testing that, I tried it with and without the ' delimiter around the variable in the values section but still keep getting the "Syntax error in INSERT INTO statement" error.
Any thoughts?