Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding fields to a table in code

Status
Not open for further replies.
Jul 8, 2002
61
US
I know there has to be a way to add new fields to an existing table in code. I've tried creating a SQL statement string that contains "ALTER TABLE testdata ADD newfield text null;" and then executing the statement in code. The problem is I can't figure out how to add more than 1 field at a time. Basically I can't figure out how to make the "Alter Table" statement add more than one field at a time. Any suggestions? I'm open to other ways of doing it...
 
Maybe just '|'. Can't say for sure, though. I haven't used ALTER. Might need {} as well.

Here's VB code:
Dim fld As Field
Set fld = CurrentDb.TableDefs(&quot;<tblname>&quot;).CreateField(&quot;<fldname>&quot;, dbText[, size])
CurrentDb.TableDefs(&quot;<tblname>&quot;).Fields.Append fld

Check CreateField in Help for more info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top