1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    intIndex = 0
    For Each tdfTableDef In dbsApplication.TableDefs
      If (tdfTableDef.Attributes And dbAttachedTable) <> 0 Or (tdfTableDef.Attributes And dbAttachedODBC) <> 0 Then
        astrTableName(intIndex) = tdfTableDef.Name
        alngAttributes(intIndex) = tdfTableDef.Attributes
        intIndex = intIndex + 1
      End If
          
    Next
  
    intIndex = 0
    For Each varTableName In astrTableName
      If varTableName <> "" Then
        dbsApplication.TableDefs.Delete varTableName
      
        Set tdfTableDef = dbsApplication.CreateTableDef(CStr(varTableName), _
                                                        0, _
                                                        CStr(varTableName), _
                                                        "ODBC;" & _
                                                        "DSN=XXXXX;" & _
                                                        "APP=Microsoft Office 2003;" & _
                                                        "WSID=XXXXX;" & _
                                                        "DATABASE=XXXXX;" & _
                                                        "Trusted_Connection=Yes")
                                      
        dbsApplication.TableDefs.Append tdfTableDef
      End If
      
      astrTableName(intIndex) = ""      
    Next