By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

VB syntax error

P: 19
HI, I am getting a sytax error saying that I have a comma that is not in a correct place. I have re-written this code many times over in idfferent forms and I am still getting the runtime syntax error,

Thanks for the help

mStringSQL = "DELETE Driver_daily_logs.emp_id, Driver_daily_logs.date_recieved, " _
& "Driver_daily_logs.violation, Driver_daily_logs.form_manner, Driver_daily_logs.log_status, " _
& "Driver_daily_logs.status_date, Driver_daily_logs.date_destroyed " _
& "Driver_daily_logs.comments, Driver_daily_logs.log_id " _
& "FROM Driver_daily_logs"
& "Where GetDate() > date_destroyed "
May 29 '08 #1
Share this Question
Share on Google+
13 Replies


jeffstl
Expert 100+
P: 432
HI, I am getting a sytax error saying that I have a comma that is not in a correct place. I have re-written this code many times over in idfferent forms and I am still getting the runtime syntax error,

Thanks for the help

mStringSQL = "DELETE Driver_daily_logs.emp_id, Driver_daily_logs.date_recieved, " _
& "Driver_daily_logs.violation, Driver_daily_logs.form_manner, Driver_daily_logs.log_status, " _
& "Driver_daily_logs.status_date, Driver_daily_logs.date_destroyed " _
& "Driver_daily_logs.comments, Driver_daily_logs.log_id " _
& "FROM Driver_daily_logs"
& "Where GetDate() > date_destroyed "
Your missing a comma between

& "Driver_daily_logs.status_date, Driver_daily_logs.date_destroyed " _
& "Driver_daily_logs.comments, Driver_daily_logs.log_id " _

SQL can be frustrating because when the querys get really big it is hard to troubleshoot them. But be patient, seperate out sections if you have to in notepad or something and go over them carefully.
May 29 '08 #2

P: 19
Thanks for the help, I am just getting used to doing SQL in VB
May 29 '08 #3

jeffstl
Expert 100+
P: 432
Thanks for the help, I am just getting used to doing SQL in VB
No problem

Yeah I understand. Like I said the bigger the SQL query the more difficult it becomes to troubleshoot, so sometimes you just have to do the old "stare and compare" by eye.
May 29 '08 #4

P: 19
No problem

Yeah I understand. Like I said the bigger the SQL query the more difficult it becomes to troubleshoot, so sometimes you just have to do the old "stare and compare" by eye.
Now even with adding in the comma that was missing I am still getiign an erro message saying incorrect syntax near ' , '


mStringSQL = "DELETE Driver_daily_logs.emp_id, Driver_daily_logs.date_recieved, " _
& "Driver_daily_logs.violation, Driver_daily_logs.form_manner, Driver_daily_logs.log_status, " _
& "Driver_daily_logs.status_date, Driver_daily_logs.date_destroyed, " _
& "Driver_daily_logs.comments, Driver_daily_logs.log_id " _
& "FROM Driver_daily_logs " _
& "Where GetDate() > date_destroyed "
May 29 '08 #5

jeffstl
Expert 100+
P: 432
Now even with adding in the comma that was missing I am still getiign an erro message saying incorrect syntax near ' , '


mStringSQL = "DELETE Driver_daily_logs.emp_id, Driver_daily_logs.date_recieved, " _
& "Driver_daily_logs.violation, Driver_daily_logs.form_manner, Driver_daily_logs.log_status, " _
& "Driver_daily_logs.status_date, Driver_daily_logs.date_destroyed, " _
& "Driver_daily_logs.comments, Driver_daily_logs.log_id " _
& "FROM Driver_daily_logs " _
& "Where GetDate() > date_destroyed "
Ok. Off hand I dont see the problem but first lets try to simplify your problems. I assume that all of those columns in your query are pretty much the whole of a "record". So instead of doing all that mess just do this

DELETE * FROM Driver_daily_logs WHERE CURRENT_TIMESTAMP > date_destroyed

Much easier....

Then, the next thing is I have no idea how date_destroyed is formatted. Is it a Day? is it mm/dd/yyyy? is it a julian date?

You have to make sure whatever SQL returnes for CURRENT_TIMESTAMP, or whatever you end up using, has to match the same format as whatever is stored in date_destroyed.
May 29 '08 #6

P: 19
ya date_destroyed is in that format
May 29 '08 #7

P: 19
sorry the date is in dd/mm/yyyy
May 29 '08 #8

jeffstl
Expert 100+
P: 432
ya date_destroyed is in that format
Which format?

CURRENT_TIMESTAMP?
CURRENT_DATE?
CURRENT_TIME?

Each of these qill return a different formatted data so which are you using and which one best matches date_destroyed?

Also make sure that date_destroyed is in fact a date data type in your database.

You may have to play with the SQL CAST function if it isnt.
May 29 '08 #9

P: 19
and now when i use
mStringSQL1 = "DELETE * FROM Driver_daily_logs WHERE CURRENT_TIMESTAMP > date_destroyed"

it is giving me an erro on the * saying that it is incorrect syntax near '*'
May 29 '08 #10

P: 19
i am using the current_date
May 29 '08 #11

jeffstl
Expert 100+
P: 432
sorry the date is in dd/mm/yyyy
OK. So you want CURRENT_DATE then probably.
May 29 '08 #12

jeffstl
Expert 100+
P: 432
and now when i use
mStringSQL1 = "DELETE * FROM Driver_daily_logs WHERE CURRENT_TIMESTAMP > date_destroyed"

it is giving me an erro on the * saying that it is incorrect syntax near '*'

Really? Wow. Um. What kind of database are you using?

You could just try it without the * because that should technically work as well.

mStringSQL1 = "DELETE FROM Driver_daily_logs WHERE CURRENT_DATE > date_destroyed"
May 29 '08 #13

P: 19
I am uisng SQL server 2005, and for some reason it donts like any date format i am trying to use i get an error saying that the current_date is incorrect syntax
May 29 '08 #14

Post your reply

Sign in to post your reply or Sign up for a free account.