UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Adding Columns to a Table using code    
 
   
mwacardsfan
post Jan 10 2006, 02:43 PM
Post #1

UtterAccess Guru
Posts: 594
From: Cleveland, OH



Anyone know how to use code to add columns to an existing table?
Go to the top of the page
 
+
freakazeud
post Jan 10 2006, 02:51 PM
Post #2

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
check out the alter command:

Currentdb.Execute "Alter Table TableName Add Column FieldName Text"

You can find more examples searching on UA.
HTH
Good luck
Go to the top of the page
 
+
mwacardsfan
post Jan 10 2006, 02:55 PM
Post #3

UtterAccess Guru
Posts: 594
From: Cleveland, OH



great. Thanks.

One other quick question. how do you define the new column's format to be anything other than text?

Such as integer, double, percent?

Thanks again.
Go to the top of the page
 
+
freakazeud
post Jan 10 2006, 03:00 PM
Post #4

UtterAccess VIP
Posts: 31,413
From: NC, USA



As mentioned search UA.
Instead of text define it as whatever you want. The syntax is:

CurrentDB.Execute "ALTER TABLE tableName ADD COLUMN columnName DataType"

datatype:

DATETIME
Text
BoolField YESNO
Integer
Single
Double
...

HTH
Good luck
Go to the top of the page
 
+
mwacardsfan
post Jan 10 2006, 03:04 PM
Post #5

UtterAccess Guru
Posts: 594
From: Cleveland, OH



thanks1
Go to the top of the page
 
+
freakazeud
post Jan 10 2006, 03:05 PM
Post #6

UtterAccess VIP
Posts: 31,413
From: NC, USA



You're welcome.
Glad I could assist!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th June 2013 - 11:56 PM