Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop 2 tables via vfp code or access code
Message
From
17/11/2005 17:23:48
 
General information
Forum:
Visual Basic
Category:
Access
Miscellaneous
Thread ID:
01069682
Message ID:
01069988
Views:
9
I don't think he is talking about linked tables. And the reason your code may fail is due to the index as you mention, but that of the collection.

To remove all items from a collection you should instead use a descending for .. next loop, (step -1) as opposed to a for each loop.

>Do you mean delete the tables from the mdb? Are these tables Access tables or are they linked to another source? Could you please provide mode details?
>
>Thanks!
>
>Oh, Here is a quick script that will drop all linked tables, I think it would be easy to change it to accept paramenters of the table names. Just put this is an access module. All you might need is this command:
>dbLocal.TableDefs.Delete tdf.NAME
>NAME being the table name, and I would call it twice since sometimes the indexes change, look at the logic below..
>
>Here is the full function:
>
>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
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform