Delete a Column from Access (DAO)

Hello All,

How do i use DAO to remove a existing column?

thank you
RayneAsked:
Who is Participating?
 
aikimarkConnect With a Mentor Commented:
something like this:
dbengine(0)(0).TableDefs("yourtablename").Fields.Delete  "yourfieldname"

Open in new window

0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
use this command


currentdb.execute "alter table tablename drop column columnname"
0
 
RayneAuthor Commented:
Thank you all,

AikiMark, this is Awesomosity in just one line :)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Rey Obrero (Capricorn1)Commented:
my post that was posted earlier is also a one liner ?????
0
 
RayneAuthor Commented:
Hello Rey,

Sure, I understand.  I was looking for something that could use variables so that its reusable and dynamic :)
and something I can use as standalone function and pass column variables to delete the ones I want..
0
 
aikimarkCommented:
@Rayne
I was looking for something that could use variables
You can.
currentdb.execute "alter table " & yourtablenamevariable & " drop column " & yourcolumnnamevariable

Open in new window

In the above version of Rey's statement, the two variable name references could also be parameter names to a routine in which this statement resides.
0
 
RayneAuthor Commented:
thank you Aikimark for indicating that.
0
 
Rey Obrero (Capricorn1)Commented:
@Rayne
I was looking for something that could use variables

you should have included that in your original posts.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.