(21-08-13, 09:39 AM)Noname Đã viết: Bạn post file lên mình xem thử.
--------------------
Private Sub cmdOpen_Click()
txtPath.Value = getFile("Select Data File", "data file", "*.mdb", "*.accdb")
End Sub
Private Sub cmdreLink_Click()
LinkTable "Cong_suat", txtPath
LinkTable "Data_DL", txtPath
LinkTable "Data_KH", txtPath
LinkTable "Dien_ap", txtPath
LinkTable "Dong_dien", txtPath
LinkTable "Hieu_loai", txtPath
LinkTable "Loai_tb", txtPath
LinkTable "Nuoc_sx", txtPath
LinkTable "tblEmployees", txtPath
LinkTable "Ten_dday", txtPath
LinkTable "Ten_don_vi", txtPath
LinkTable "Thoi_han", txtPath
LinkTable "UsysRibbons", txtPath
' SýÒa tên caìc table týõng ýìng thaÌnh cuÒa baòn
MsgBox " Da nhap thanh cong Data " & txtPath
End Sub
---------------------
Modul là:
Option Compare Database
Function getFile(Tit As String, formatName As String, formatType As String)
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
With dlgOpen
.Title = Tit
.Filters.Clear
.Filters.Add formatName, formatType
.AllowMultiSelect = False
result = .Show
If (result <> 0) Then
getFile = Trim(dlgOpen.SelectedItems.Item(1))
End If
End With
End Function
Sub LinkTable(T As String, path As String)
' kiêÒm tra table, nêìu coì rôÌi thiÌ xoìa ði
On Error GoTo Err
DoCmd.DeleteObject acTable, T
Err:
'link lai tablelink moi
DoCmd.TransferDatabase acLink, "Microsoft Access", path, acTable, T, T
End Sub
----------
----------