473,386 Members | 1,654 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,386 software developers and data experts.

Deleting a list of tables from a database

There is a table that lists all of the linked DBF tables in the current database in the field "ForeignName". I need to create code that will delete all these tables whose names are in the "ForeignName" field (the table is created from a make table query the filters on *DBF names in this field).

This code will be distributed to a about 50 employees in our dept. We are trying to automate this process so that employees do not have to manually delete 15 or 20 linked tables in their databases.

Any help is appreciated.
Apr 26 '13 #1
2 1275
ADezii
8,834 Expert 8TB
  1. Create a Recordset based on the Table containing the Names of the Tables to be Deleted.
  2. Loop through this Recordset, and for each Record, Delete the Table with the corresponding [ForeignName].
  3. The Pseudo Code would look something like this:
    Expand|Select|Wrap|Line Numbers
    1. On Error Resume Next
    2.  
    3. 'Recordset rs previously created
    4. With rs
    5.   Do While Not .EOF
    6.     CurrentDB.Tabledefs.Delete ![ForeignName]
    7.       .MoveNext
    8.   Loop
    9. End With
Apr 26 '13 #2
NeoPa
32,556 Expert Mod 16PB
If the only requirement is to delete all linked tables then a separate table to store them in is unnecessary. The TableDefs() collection contains each TableDef in the database, and each has a Connection property from which it is easy to determine whether or not it is linked, and how.
Apr 27 '13 #3

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

Similar topics

1
by: Sebastian | last post by:
Hi I got a little problem with deleting from my database, i'm making a simple newsscript. I get a Parse error: syntax error, unexpected T_ELSE on line 24, I have written the error as a comment...
11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
9
by: Peter Moscatt | last post by:
Is there a SQL command I can issue which will list all the TABLES within a database ? Pete ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9'...
3
by: maricel | last post by:
Is there a way to list (using db2 command or catalogs) to list hierarchy of table parent & child relationship: 1) A list that shows which table should be deleted first,second,third... 2) A list...
4
by: john | last post by:
When leaving the main menu form I want to delete some temporary tables. The following code on the form's close works: DoCmd.DeleteObject acTable, "tmpEnvelop". But is it possible to change it so...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
0
by: jaeden99 | last post by:
I have a two drop down list box. The first contains district name(district id is the value) and the the second will contain the user name based on the district selected in the first drop down list....
2
by: Danny | last post by:
Hello, We imported a bunch of tables from a database and realized that the primary keys weren't copied to the destination db. In order to re- create the keys, we need to know which tables have...
9
by: hooijdonk | last post by:
Hi, using a form I have been trying to get a list box to display the values of database table and have two options on there. a) the user can select a list item and click a button to delete that...
4
by: Erwin Leonardi | last post by:
Hi there, Suppose computer PC1 is my database server in which DB2 is running. I have an application running in computer PC2. The application PC2 will connect to DB2 in PC2. How can my...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.