G
Guest
hi guys
i want to import an excel sheet to access database, but it gives me the
error :
3051 The Microsoft Jet database engine cannot open the file <name>. It is
already opened exclusively by another user, or you need permission to view
its data.
i have full permission on the file and full permission (read/write..) on the
database..
any thought?
here is my code:
Dim kmspPath As String
Set fs = Application.FileSearch
'kmspPath = Application.CurrentProject.Path & "\KMSP\"
kmspPath = Application.CurrentProject.Path
Set myDB = CurrentDb()
Dim temp As DAO.Recordset
Set temp = myDB.OpenRecordset("KMSPTemp", dbOpenTable)
With fs
.LookIn = Application.CurrentProject.Path
'.LookIn = Application.CurrentProject.Path & "\KMSP\"
.FileName = "*.xls"
If .Execute(SortBy:=msoSortbyFileName, SortOrder:=msoSortOrderAscending)
strPath = .FoundFiles(i)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"" & "temp" & "", kmspPath, False
Next i
Else
MsgBox "There were no files found."
End If
End With
thanks
i want to import an excel sheet to access database, but it gives me the
error :
3051 The Microsoft Jet database engine cannot open the file <name>. It is
already opened exclusively by another user, or you need permission to view
its data.
i have full permission on the file and full permission (read/write..) on the
database..
any thought?
here is my code:
Dim kmspPath As String
Set fs = Application.FileSearch
'kmspPath = Application.CurrentProject.Path & "\KMSP\"
kmspPath = Application.CurrentProject.Path
Set myDB = CurrentDb()
Dim temp As DAO.Recordset
Set temp = myDB.OpenRecordset("KMSPTemp", dbOpenTable)
With fs
.LookIn = Application.CurrentProject.Path
'.LookIn = Application.CurrentProject.Path & "\KMSP\"
.FileName = "*.xls"
If .Execute(SortBy:=msoSortbyFileName, SortOrder:=msoSortOrderAscending)
For i = 1 To .FoundFiles.Count0 Then
strPath = .FoundFiles(i)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"" & "temp" & "", kmspPath, False
Next i
Else
MsgBox "There were no files found."
End If
End With
thanks