473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Drop Table

I KNOW this will sound silly asking and I promise I have read every possible post all over the internet, but for some reason I can not get my Drop Table command to work.

The Access '03 tables I want to delete/drop are automatically created when the import is initiated. Each table has "ImportErrors" verbaige in it's name, but the suffix of the name is a sequential running based on the number of files imported.

Exactly how would i automate the droping of these tables? Macro calling a module? Macro calling a SQL qry? Macro with a SQL stmt in it? Nothing I do seems to work. Please help me!!

Thank you in advance
Dec 19 '07 #1
8 1897
FishVal
2,653 Expert 2GB
Hi, there.

You've surprised me. ;)
The following SQL statement drops table without any problem.
Expand|Select|Wrap|Line Numbers
  1. DROP TABLE <TableName>;
  2.  
Regards,
Fish
Dec 19 '07 #2
But, I have multiple tables, that all have different endings to their table names, so I can't get the Drop Table to work with any type of "wildcard" characters
Dec 19 '07 #3
FishVal
2,653 Expert 2GB
But, I have multiple tables, that all have different endings to their table names, so I can't get the Drop Table to work with any type of "wildcard" characters
The following procedure will do it.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DropMultipleTables(strLike As String)
  2.  
  3.     Dim tbl As DAO.TableDef
  4.  
  5.     For Each tbl In CurrentDb.TableDefs
  6.         If tbl.Name Like strLike Then CurrentDb.TableDefs.Delete tbl.Name
  7.     Next
  8.  
  9.     Set tbl = Nothing
  10.  
  11. End Sub
  12.  
Dec 19 '07 #4
ok...i must be close, because I'm not getting any errors...but I'm not seeing where anything is happening either. The tables I'm attempting to drop are still showing..

I know I'm missing something simple, it's because I've been working on this for TOO long!!

I pasted your code into a new module and set to view watch, but nothing is getting triggered.....any thoughts? Other than the obvious...I'm stupid! :o)

Thank you for helping me, I so greatly appreciate it.
Dec 19 '07 #5
FishVal
2,653 Expert 2GB
:)

Do you include wildcards in the sub argument?
Like the following:
DropMultipleTables "Table*"

Certainly I've tested the code. It works just fine deleting [Table1], [Table2], [Table3].
Dec 19 '07 #6
jaxjagfan
254 Expert 100+
Try this for the error tables. Its a Function I use in a module to drop tables with the "_InportErrors" in its name. You can call the function from your import routines.

Expand|Select|Wrap|Line Numbers
  1. Public Function CleanErrors()
  2.  
  3. Dim tname As TableDef
  4. Dim db As Database
  5. Dim tdef As TableDefs
  6. On Error Resume Next
  7. Set db = DBEngine(0)(0)
  8. Set tdef = db.TableDefs
  9.  
  10. For Each tname In tdef
  11.     If tname.Name Like "*_ImportErrors*" Then
  12.     DoCmd.DeleteObject acTable, tname.Name
  13.     End If
  14. Next
  15.  
  16. End Function
  17.  
Dec 19 '07 #7
Thank you both so much!

JaxJagFan,
Your coding is "exactly" what I was trying to come up with and for the same purpose. It ran like a deer!!!

Thank you so very much.
P.S. Jax Jag huh? I believe we're in the same location
Dec 20 '07 #8
jaxjagfan
254 Expert 100+
HTH

Have had same issue. I keep a lot of my previous Access projects in a folder I call Toolbox. Some date back over 10 years.

BTW - Jacksonville (Mandarin) and will be at the game on Sunday.
Dec 20 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James Knowlton | last post by:
Hello, I'm just returning to MS SQL Server after two years of dealing with Sybase ASE. I need to drop a column, using the alter table command. I keep getting an error indicating that a...
2
by: Ryan | last post by:
Just a quicky about temporarary tables. If using QA, when you create a temporary table, it gets dropped if you close the query. Otherwise you need to state 'DROP TABLE myTable' so that you can...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
5
by: Markus | last post by:
I tried this: ALTER TABLE Dokumente DROP COLUMN docPrioID but I get this errormessage: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: COLUMN;ABLE Dokumente DROP;CONSTRAINT
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: sparksol | last post by:
I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display. I would like to keep the...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
4
by: Joseph | last post by:
Can i drop a cloumn from a table in DB2 for Z/OS?
10
by: Dean | last post by:
My client has a db I am working that uses temp tables. During an update procedure, I had the code If fTableExists(tempTblName) = True Then DoCmd.DeleteObject acTable, tempTblName Then I thought...
11
by: tokcy | last post by:
Hi everyone, I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database. I mean i have three dropdown 1....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.