Alter Column data type

nhandal

New member
Local time
Yesterday, 16:12
Joined
Sep 9, 2010
Messages
2
I have a database in which I include a macro to retrieve data from a number of excel sheets into a table. I am trying to add a line of code that changes the data type of one of the columns after all data has been retrieved.

I hope someone can help me identify what is wrong with this line:

Code:
DoCmd.RunSQL "ALTER TABLE IntradaySheet ALTER COLUMN Time datetime;"
When I run this code it returns an error message that says: "Syntax error in ALTER TABLE statement"

Thank you in advance.
 
It's because of the field named with a reserved word (Time). I'd change that, but if you can't try:

DoCmd.RunSQL "ALTER TABLE IntradaySheet ALTER COLUMN [Time] datetime;"
 
pbaldy,

Thank you very much, it works with the [Time] syntax as you suggested. That was really helpful.
 
Happy to help, and welcome to the site by the way.
 

Users who are viewing this thread

Back
Top Bottom