Insert a field in sql using VB

C

chris.nebinger

Check out ALTER TABLE in the help.

This would be done like:

ALTER TABLE Table1 ADD COLUMN Field1 Text (255)
From a VBA Code:

CurrentDB.Execute "ALTER TABLE Table1 ADD COLUMN Field1 Text (255)"


Chris Nebinger
 
V

Vino

Thanks 4 ur valuable suggestion .

I've tried calling as a function and succeeded with a minor change in
coding.

Sub sChangeField (strTableName As String, strFieldName As String,
strFieldType As String)
strSQL = "ALTER TABLE [" & strTableName & "] ADD [" & strFieldName & "]
" & strFieldType & ";"
db.Execute strSQL
end sub

Call sChangeField ("tblName","fldName","TEXT (100)")

--------------------------------------------------------------------------------------------------------------------------
 
Top