>Function DropAttachedTables() As Boolean >If intDebug = 1 Then Debug.Print "->modMain.DropAttachedTables [F]" >'-----------------------------------+-----------------------+---------------+ >' Purpose: Drop all attached tables >'-----------------------------------+-----------------------+---------------+ > Dim dbLocal As Database > Dim tdf As TableDef > Dim fDropped As Boolean > Set dbLocal = CurrentDb() > Do > ' one simple loop will fail to unattach all tables > ' so we'll redo the unattach until nothing gets > ' unattached. > fDropped = False > For Each tdf In dbLocal.TableDefs > If Len(tdf.Connect) Then > ''Debug.Print "Dropping Linked Table " & tdf.name > dbLocal.TableDefs.Delete tdf.NAME > fDropped = True > End If > Next > Set tdf = Nothing > If Not fDropped Then > ' if nothing dropped then we've unattached all the tables > Exit Do > End If > Loop > Set dbLocal = Nothing > DropAttachedTables = True > If intDebug = 1 Then Debug.Print "<-modMain.DropAttachedTables [F]" >End Function >