NB. This answer was given in "Importing CSV Files" thread. Please read this for further details.
If this does not help, let me know. I would probably use a test database before executing any code that you see on any forum. Its easier to resolve problems that way.
'-------------------
OK, however I would make a point of ensuring that the same files don't get imported twice (otherwise you will have duplicate data and/or errors)
before I give you the code, I will firstly let you know what it does.
If you put in :
Call MyImportFnctn("C:\My Documents"
Then it will look through "C:\my documents" for all csv files. It will then create tables of the same name, so, if your "C:\My Documents" folder contains :
melisadata.csv
noreendata.csv
then two tables would appear in your database, one called "melisadata", and the other called noreendata. Each containing its own data from the csv files respectively
here is the code :
Public Sub MyImportFnctn(Byval Pathnm as string)
'N.B. Ensure "Path" points to folder where csvs will be located. Eg. C:\My Documents
'filesystem object used for file I/O
Set fs = Application.FileSearch
With fs
.LookIn = Pathnm
.FileName = "*.csv"
If .Execute(SortBy:=msoSortbyFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
'if they are found, then import into table
Docmd.TransferText acImportDelim, , Left$(.FoundFiles(i), Len(.FoundFiles(i)) - 4), .FoundFiles(i) , False
msgbox("Imported : " & .FoundFiles(i))
Next i
Else
MsgBox "There were no csv files found."
End If
End With
Msgbox("Done"
End Sub
'----------------------
Hope your happy with that.
Regards,
Mr Big.