error 3051/plz help

  • Thread starter Thread starter Guest
  • Start date Start date
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)
For i = 1 To .FoundFiles.Count

strPath = .FoundFiles(i)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"" & "temp" & "", kmspPath, False
Next i
Else
MsgBox "There were no files found."
End If
End With

thanks
 
Does this happen with every workbook in the folder, or just with one or
more particular workbooks?
 
Mr. Nurick,
I am having a similiar problem. I am trying to export to a text file from
access. When I tell it to export, I get the error about the jet database not
being able to open the file. No one else is using this file, and I am saving
it to my harddrive. Any suggestions to what might cause this?
 
There can be a variety of causes for 3051 errors when creating text
files. They seem to include

-Insufficient permissions on the folder where the file is being created
-A non-standard file extension (if you're using something other than
..txt or .csv, try changing it)
-The file already exists and has been locked by another process (or, in
one case i saw, by your own application)
-Maybe, the file is read-only.
 
Back
Top