PDA

View Full Version : Alter table add column help



enfrspit
02-23-2011, 12:01 AM
Hi everyone, i'm very amateur in VB for Access. I'm just one add a column into a table automatically. I've a table named "Nghich". Now i want to add a text filed into this table. I name the field "Hehe". What i write is:

Private Sub Toggle8_Click()

Dim SQL2 As String
SQL2 = "ALTER TABLE Nghich ADD COLUMN Hehe TEXT(255)"
DoCmd.RunSQL SQL2
MsbBox ("Done")

End Sub

I do realize it's simple, but i've not succeeded to compile the right syntax. It always says:" Compile error: Sub or Function not defined"
Please, help me.

Thank all of you for your help.

OBP
02-26-2011, 12:09 PM
This should add a field called HeHe
DoCmd.RunSQL "ALTER TABLE Nghich ADD COLUMN [HeHe] (255);"

OBP
02-26-2011, 12:18 PM
I just tested it and it works for me.

enfrspit
02-28-2011, 07:10 PM
Thank OBP, it works for me too. Thank u very much.