Solved

Delete a Column from Access (DAO)

Posted on 2014-04-21
9
509 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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 …
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now