Home

Adding a New Column to an Existing Table

 

Description

To add a new column to an existing table, a column, use the following formula:

ALTER TABLE TableName
ADD COLUMN ColumnName DataType

The TableName must specify the table that has the column.

The ColumnName must be a valid name for the new column and you must follow the rules for naming columns. The data type must be one of those we reviewed. Here is an example that adds a new string-based column named CellPhone to a table named Contractors:

ALTER TABLE Contractors ADD COLUMN CellPhone TEXT;

Remember that you can include the statement in the RunSQL() method of the DoCmd class:

Private Sub cmdAlterPersons_Click()
    DoCmd.RunSQL "ALTER TABLE Contractors ADD COLUMN CellPhone TEXT;"
End Sub

 

 

Home Copyright © 2009-2016, FunctionX, Inc.