If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding a Field to a Table using code.
Does anyone know how to add or delete a field from a table using VBA?
|
#2
|
|||
|
|||
Adding a Field to a Table using code.
Method 1: DDL
Execute a query statement such as: "ALTER TABLE MyTable ADD COLUMN MyColumn TEST;" "ALTER TABLE MyTable DROP COLUMN MyColumn;" Method 2: DAO Use CreateField() and then Append to the Fields collection of the TableDef. Delete the Field from the Fields collection of the TableDef Method 3: ADOX Declare a new ADOX.Column, and Append to the Columns of the Table. Use method 1 for a quick and simple approach. Use method 2 if you want fine control over the properties of the new field. Use method 3 if you are a maschochist. (ADOX is very buggy, with different bugs in different versions so you never know what you will end up with.) -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Luis Medina" wrote in message ... Does anyone know how to add or delete a field from a table using VBA? |
#3
|
|||
|
|||
Adding a Field to a Table using code.
Thanks for your help.
|
Thread Tools | |
Display Modes | |
|
|