I am trying to delete the links to attached tables, while keeping the system tables and a couple of others.
Here is my code, run off a command button:
Private Sub Command71_Click()
Dim db As Database
Dim tblD As TableDef
Set db = CurrentDb()
For Each tblD In db.TableDefs
If Not Left(tblD.Name, 7) = "DCtable" Then 'tables to be kept
If Not Left(tblD.Name, 4) = "Msys" Then 'system tables
db.TableDefs.Delete tblD.Name
End If
End If
Next
db.TableDefs.Refresh
Set db = Nothing
DoCmd.RunCommand acCmdLinkTables
End Sub
I have approx twenty attached tables. When I run the above code it deletes less than half of them. Does anyone know where I am going wrong?
Any help gratefully received.
TIA,
Rich
Lead Developer
Here is my code, run off a command button:
Private Sub Command71_Click()
Dim db As Database
Dim tblD As TableDef
Set db = CurrentDb()
For Each tblD In db.TableDefs
If Not Left(tblD.Name, 7) = "DCtable" Then 'tables to be kept
If Not Left(tblD.Name, 4) = "Msys" Then 'system tables
db.TableDefs.Delete tblD.Name
End If
End If
Next
db.TableDefs.Refresh
Set db = Nothing
DoCmd.RunCommand acCmdLinkTables
End Sub
I have approx twenty attached tables. When I run the above code it deletes less than half of them. Does anyone know where I am going wrong?
Any help gratefully received.
TIA,
Rich
Lead Developer