If DataTables.Contains("动态表列") = False Then Dim Builder As New ADOXBuilder Dim tbl As ADOXTable Builder.Open() tbl = Builder.NewTable("动态表列") '创建表 With tbl For Each r As Row In Tables("表A").Rows If r("证书编号") > "" Then .AddColumn(r("证书编号") ,ADOXType.String, 16) End If Next End With Builder.AddTable(tbl) '增加表 Builder.Close() Syscmd.Project.Open(ProjectFile) Else Dim str1,str2 As String For Each r As Row In Tables("表A").Rows If r("证书编号") > "" Then str1 + = r("证书编号") & "|" End If Next For Each dc As DataCol In DataTables("动态表列").DataCols str2 + = dc.Name & "|" Next If str1 <> str2 Then Dim Builder As New ADOXBuilder Builder.Open() '打开ADOXBuilder With Builder.Tables("动态表列") For Each r As Row In Tables("表A").Rows If r("证书编号") > "" AndAlso str2.Contains(r("证书编号")) = False Then .AddColumn(r("证书编号") ,ADOXType.String, 16) End If Next For Each s As String In str2.Trim("|").Split("|") If str1.Contains(s) = False Then With Builder.Tables("动态表列") .DeleteColumn(s) End With End If Next End With Builder.Close() '关闭ADOXBuilder Syscmd.Project.Open(ProjectFile) End If End If
|