Public Sub Tablsx(Strtext As String) '刷新联连表,参数为联接表的址及文件名,USYS_Tabl是存放联接表名的表。 Dim hdk As String Dim cat As ADOX.Catalog Dim tdf As ADOX.Table
hdk = Strtext Set cat = New ADOX.Catalog Set cat.ActiveConnection = CurrentProject.Connection Dim db As ADODB.Connection
Dim rs As Recordset Dim BIAO As String Set db = New ADODB.Connection Set rs = New ADODB.Recordset rs.ActiveConnection = CurrentProject.Connection rs.Open "USYS_Tabl", , adOpenKeyset, adLockOptimistic, adCmdTable rs.MoveFirst Do Until rs.EOF BIAO = rs!id Set tdf = cat.Tables(BIAO) tdf.Properties("jet oledb:link datasource") = hdk rs.MoveNext Loop rs.Close DoCmd.Close End Sub
************************** 全部表都是联接表时用 Public Sub Ffff(strtext As String)
Dim cat As ADOX.Catalog Dim tdf As ADOX.Table
Set cat = New ADOX.Catalog Set cat.ActiveConnection = CurrentProject.Connection For I = 6 To cat.Tables.count Set tdf = cat.Tables(I) tdf.Properties("jet oledb:link datasource") = strtext