-
Jun 23rd, 2015, 12:43 AM
#1
Thread Starter
Hyperactive Member
insert statement-Syntax error
I don't which part when wrong, i had been googling for hours and now() is suppose to give us a timestamp but when i print out the sql i got this syntax error.
can someone advice me which syntax error in my insert statement is occuring?
Code:
sql = "Insert into Followup(Followup, FollowUpDate, Check, CompanyName, Category, Timestamp) Values ('" & Me.txt_f1 & "', '" & Me.txt_fdate1 & "', '" & Me.chk_r1 & "', '" & Me.lb_companyName & "','" & Me.lb_category & "', NOW())"
MsgBox sql
Here is what is shows in the print out msgbox.
-
Jun 23rd, 2015, 05:16 AM
#2
Re: insert statement-Syntax error
try
Code:
sql = "Insert into Followup(Followup, FollowUpDate, Check, CompanyName, Category, Timestamp) Values ('" & Me.txt_f1 & "', '" & Me.txt_fdate1 & "', '" & Me.chk_r1 & "', '" & Me.lb_companyName & "','" & Me.lb_category & "'," & NOW() & ")"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 23rd, 2015, 06:28 AM
#3
Re: insert statement-Syntax error
Still not quite right... need enclosing ticks around the timestamp value.
Even still... parameters would be a better way to go. Also I think (think, not sure) that TmeStamp might be a reserved word ... it's a type in SQL Server.
-tg
-
Jun 23rd, 2015, 03:56 PM
#4
Re: insert statement-Syntax error
need enclosing ticks around the timestamp value
also if timestamp is a date field, probably should be hashes instead
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 23rd, 2015, 09:09 PM
#5
Thread Starter
Hyperactive Member
Re: insert statement-Syntax error
This code works for the timestamp. Thanks.
Originally Posted by westconn1
try
Code:
sql = "Insert into Followup(Followup, FollowUpDate, Check, CompanyName, Category, Timestamp) Values ('" & Me.txt_f1 & "', '" & Me.txt_fdate1 & "', '" & Me.chk_r1 & "', '" & Me.lb_companyName & "','" & Me.lb_category & "'," & NOW() & ")"
but the timestamp still remain unresolve. As i did try to change the word timestamp to TS, the error still occurred.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|