Excel VBA to Drop Table in Access

jo15765

Well-known Member
Joined
Sep 23, 2011
Messages
591
I found this code (I can't find the link back to it now :()
Code:
Sub RemoveTempTable()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim dbName() As Variant
Dim q As Variant

dbName = Array("One", "Two", "Three")
Set db = OpenDatabase("C:\" & dbName(q) & "\" & dbName(q) & "RPT.mdb")
For q = LBound(dbName) To UBound(dbName)
    db.TableDefs.Delete "tbl_Test"
Next q
End Sub

The problem I have is I tweaked the code to work for an array of databases, and it is only updating the 1st database, it is not dropping the table in the subsequent databases. What did I code wrong?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,202,987
Messages
6,052,937
Members
444,616
Latest member
novit19089

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top