help woith syntax..

N

nycdon

Anyone with good eye for syntax see the issue with this..getting syntax err..

strSql = "INSERT INTO [UpdatedTPlanMedication] ( UpdatedTPlanID#,
Medication, Reason, Response, Dose, SideEffect, IsMerged, TimeStamp ) " & _
"SELECT " & lngID & " As NewID, Medication, Reason, Response,
Dose, SideEffect, IsMerged, TimeStamp " & _
"FROM [UpdatedTPlanMedication] WHERE [UpdatedTPlan#] = " &
Me.[UpdatedTPlanID#] & ";"
DBEngine(0)(0).Execute strSql, dbFailOnError

thanks,
don
 
N

nycdon

ps..I'm down to now where it when i run in Query designer/SQL view, it gives
syntax error and highlights
the TimeStamp field..(linking to sql server table)

thanks,
don
 
J

John Spencer

If TimeStamp is really a field of the type TimeStamp, I think you should
drop it from the query. TimeStamps are system generated.

timestamp data type: A SQL Server system data type that is a monotomically
increasing counter whose values are always unique within a database.
Also, I would bracket your fields with # marks
 
J

John Vinson

ps..I'm down to now where it when i run in Query designer/SQL view, it gives
syntax error and highlights
the TimeStamp field..(linking to sql server table)

SQL timestamps are not updateable - they're maintained automatically.
I'd suggest just leaving the field out of both the INSERT INTO and
SELECT clauses.

John W. Vinson[MVP]
 
N

nycdon

Thanks so much John!

John Spencer said:
If TimeStamp is really a field of the type TimeStamp, I think you should
drop it from the query. TimeStamps are system generated.

timestamp data type: A SQL Server system data type that is a monotomically
increasing counter whose values are always unique within a database.
Also, I would bracket your fields with # marks
nycdon said:
Anyone with good eye for syntax see the issue with this..getting syntax
err..

strSql = "INSERT INTO [UpdatedTPlanMedication] ( [UpdatedTPlanID#],
Medication, Reason, Response, Dose, SideEffect, IsMerged) " & _
"SELECT " & lngID & " As NewID, Medication, Reason, Response,
Dose, SideEffect, IsMerged" & _
"FROM [UpdatedTPlanMedication] WHERE [UpdatedTPlan#] = " &
Me.[UpdatedTPlanID#] & ";"
DBEngine(0)(0).Execute strSql, dbFailOnError

thanks,
don
 
Top