نوشته شده توسط
sajjad_kochekian
اگر بخواهیم از طریق کد نویسی این کار را انجام بدهم باید چه کاری انجام دهیم
سلام دوست من
شايد اين فانكشن نظر شما رو براورده كنه:
Public Function link2BE()
'Recreate the links to tables in the back end database. Links are removed first to prevent the possibility of duplicating tables. It may be necessary to reset the name of the back end database in the 5th line below...
Dim tdf As TableDef
Dim i As Integer, j As Integer
Dim strBE As String
If MsgBox("Relink all tables?", vbYesNo + vbQuestion, strTitle) = vbNo Then Exit Function
strBE = Application.CurrentProject.Path & "\m_be.mdb"
Set db = CurrentDb
On Error Resume Next
DoCmd.Hourglass True
For i = 0 To db.TableDefs.Count - 1
Set tdf = db.TableDefs(i)
If tdf.Properties(4) <> "" Then
If Left(tdf.Name, 4) <> "msys" Then
DoCmd.DeleteObject acTable, tdf.Name
End If
End If
Next i
Set tdf = Nothing
Set db = Nothing
Set db = DBEngine.Workspaces(0).OpenDatabase(strBE)
j = 0
For i = 0 To db.TableDefs.Count - 1
Set tdf = db.TableDefs(i)
If Left(tdf.Name, 4) <> "msys" Then
DoCmd.TransferDatabase acLink, "Microsoft Access", _
strBE, acTable, tdf.Name, tdf.Name
Else
j = j + 1
End If
Next i
DoCmd.Hourglass False
MsgBox db.TableDefs.Count - j & " tables relinked.", vbOKOnly + vbInformation, strTitle
Set tdf = Nothing
Set db = Nothing
End Function
.........................
موفق باشيد