Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Drop table

Posted on 2003-03-11
Medium Priority
Last Modified: 2010-05-01

How to drop a table from Access mdb?  My program work in this way;
I delete records from a table, then drop the whole table from mdb.
Where the table name is key-in by users. My coding as below, but
is working!  pls assist.

sqlDelBData = "delete * from " & Trim(txtYear.Text)
rs2.Open sqlDelBData, cn1, adOpenForwardOnly, adLockOptimistic, adCmdText

'Drop a table
sql = "Drop table " & Trim(txtYear.Text)
cn1.Execute sql
sql = "Drop unique index indLotNo"
sql = sql & "  on " & Trim(txtYear.Text) & "(LotNo)"
sql = sql & " with primary"
cn1.Execute sql
Question by:laysee
LVL 55

Expert Comment

by:Ryan Chong
ID: 8116805
>>My coding as below, but is working!  pls assist.
Your code is working or not?? What do you try to do?

Isn't it the code below working?
sql = "Drop table " & Trim(txtYear.Text)
cn1.Execute sql

Author Comment

ID: 8117009
Oops,  is NOT working.

Expert Comment

ID: 8117291
Can u Exaplian is there any Error Message? Or Table is Not Drppped Simply?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8117573
no error message, it just cannot drop the table.
It be able to copy records to another table(2),
and delete the records from the table(1). Just
the last part cannot drop the table.

Accepted Solution

happel earned 400 total points
ID: 8117682

You could check if you have the rights (when connected other then Admin) to perform a drop table.

If user=Admin: Could you post the exact SQL statements for wich DROP table fails, thus including your DROP Index SQL (from immediate pane)
LVL 49

Expert Comment

ID: 9664432
Hi laysee,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept happel's comment(s) as an answer.

laysee, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

572 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