Quote Originally Posted by IkkeEnGij View Post
try
"ALTER TABLE " & "[" & tbl & "]" & " ADD COLUMN "
Quote Originally Posted by saranmc View Post
yes i tried to enclose them in single quotes but in VBA Editor it does not allow me to,....
the line turns red...

Code:
Sql = "ALTER TABLE" & 'tbl' & "ADD COLUMN" & 'col' & text(10)"
the error is with the single quotes
Quote Originally Posted by saranmc View Post
It still does not work Ikke......
1) Um... I think you missed it... the quotes were to go around the field name INSIDE THE STRING... not around the variable..
2) don't use tick marks (single quotes) as that denotes a string... not an object name...
3) Square brackets IS what you want but you need to make sure it goes around the object name in the SQL string, NOT AROUND THE VARIABLE...
Ike almost had it, it just needed to be expanded:
Code:
"ALTER TABLE " & "[" & tbl & "]" & " ADD COLUMN [" & col & "] Text(128) "
What you're after is a string that ends up looking like this:
ALTER TABLE [tblSome Table] ADD COLUMN [some col] Text(128)

See how the brackets are around the object (table and col name)? that's what you're after.

-tg