Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Delete a Column from Access (DAO)

Posted on 2014-04-21
9
511 Views
Last Modified: 2014-04-22
Hello All,

How do i use DAO to remove a existing column?

thank you
0
Comment
Question by:Rayne
  • 3
  • 3
  • 2
9 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 40013935
use this command


currentdb.execute "alter table tablename drop column columnname"
0
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points
ID: 40013940
something like this:
dbengine(0)(0).TableDefs("yourtablename").Fields.Delete  "yourfieldname"

Open in new window

0
 

Author Comment

by:Rayne
ID: 40013976
Thank you all,

AikiMark, this is Awesomosity in just one line :)
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40013989
my post that was posted earlier is also a one liner ?????
0
 

Author Comment

by:Rayne
ID: 40014002
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
 
LVL 45

Expert Comment

by:aikimark
ID: 40014451
@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
 

Author Comment

by:Rayne
ID: 40014464
thank you Aikimark for indicating that.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40014617
@Rayne
I was looking for something that could use variables

you should have included that in your original posts.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question