Insert a field in sql using VB

  • Thread starter Thread starter Vino
  • Start date Start date
V

Vino

Dear All,
If anybody knows how to insert a new field in sql using vb , please let
me know. or mail me - (e-mail address removed)
 
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
 
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)")

--------------------------------------------------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top