nothingnes
Thành viên mới

- Tham gia
- 8/12/08
- Bài viết
- 8
- Được thích
- 2
Chào các anh chị,
HÔm trước em có nhờ giúp đỡ việc import excel to access và em đã làm được rồi.
Nay có 1 vấn đề nữa mà em tìm hoài không làm sao khắc phục được. Nay lại cầu cứu các anh chị.
Trong file access em đính kèm có 1 form và & table
Table DICTIONARY có các field thuộc tính đều là text
và trong form được build code là :
Private Sub importE_Click()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "D:\"
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "DICTIONARY"
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTable, strPathFile, blnHasFieldNames, "DIC!"
' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
' Kill strPathFile
strFile = Dir()
Loop
End Sub
Tất nhiên, khi import vào thì nó chỉ nhận các field có thuộc tính là text, còn những thuộc tính khác thì nó đều báo import errors
** Một vấn đề đặt ra khi em làm thao tác copy bằng tay ( select + copy) & past thẳng vào table access thì tất cả đều ok, không phát sinh lỗi.
Nên em nghĩ rằng thao tác này có thể tùy chỉnh được trong code ( em đã tìm hết và thử nhưng không làm sao giải quyết được).
Mong các anh chị giúp em trong vấn đề này ạ.
Xin chân thành cám ơn
Đây là hình mà em copy & past bằng tay ạ
HÔm trước em có nhờ giúp đỡ việc import excel to access và em đã làm được rồi.
Nay có 1 vấn đề nữa mà em tìm hoài không làm sao khắc phục được. Nay lại cầu cứu các anh chị.
Trong file access em đính kèm có 1 form và & table
Table DICTIONARY có các field thuộc tính đều là text
và trong form được build code là :
Private Sub importE_Click()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "D:\"
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "DICTIONARY"
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTable, strPathFile, blnHasFieldNames, "DIC!"
' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
' Kill strPathFile
strFile = Dir()
Loop
End Sub
Tất nhiên, khi import vào thì nó chỉ nhận các field có thuộc tính là text, còn những thuộc tính khác thì nó đều báo import errors
** Một vấn đề đặt ra khi em làm thao tác copy bằng tay ( select + copy) & past thẳng vào table access thì tất cả đều ok, không phát sinh lỗi.
Nên em nghĩ rằng thao tác này có thể tùy chỉnh được trong code ( em đã tìm hết và thử nhưng không làm sao giải quyết được).
Mong các anh chị giúp em trong vấn đề này ạ.
Xin chân thành cám ơn
Đây là hình mà em copy & past bằng tay ạ
