Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Backend Table, with a twist

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
In the past I have tested the following code to delete a table and it seemed to work.
Sub Delete_Table()
Dim cat as ADOX .Catalog
Dim strTableName as String

Set cat = New ADOX.Catalog
strTableName = “flkpTable1”
cat.ActiveConnection = CurrentProject.Connection
cat.Tables.Delete strTableName
Set cat = Nothing
End Sub

I have a odd problem now where I have a table in the backend with the same name as a table in the frontend. The backend table is not linked but I would like to delete it because it is just taking up space. The problem is this code deletes the front end table not the backend one. Not having used this code with regularity, is there a means to modify it so only the backend table will be deleted? Or, is there another means to delete the backend table only?

Any suggestions are greatly appreciated.
Eddy


 
one way

Code:
Dim mydb As Access.Application
Set mydb = CreateObject("Access.Application")
mydb.OpenCurrentDatabase "c:\test.mdb"
mydb.DoCmd.RunSQL "drop table reg"
 
way 2

Code:
Dim mydb As Database
Set mydb = DBEngine.Workspaces(0).OpenDatabase("C:\test.mdb")
mydb.Execute "drop table reg"
Set mydb = currentdb
 
try this

Code:
cat.ActiveConnection = CurrentDb.TableDefs("flkpTable1").Connect
 
Thanks for the replys pwise and pardon my ignorance but what does "drop table reg" refer to?
 
Never mind. I did some research and figured it out. Now your code works great. Thanks again.
 
Sorry about that reg is the name of a table in my test .mdb
Drop table is the sql to delete a table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top