In the thread title you wrote "Importing to accsess from CSV file error ", but then you are referencing an Excel sheetname. The file you posted has an extension of CSV, which is a text file. By default, Excel is set to open TXT/CSV files, but that does not mean they are spreadsheets.
My thought is that some of the variables are NULL in the command "DoCmd.TransferSpreadsheet" because a text file does not have a "sheetname".
Code:
DoCmd.TransferSpreadsheet acImport, , "TBL_ADD_VALUE_Genesys-temp", strfolder & "" & strFileName, , sheetname1
Also, there are several errors in the code snippet you posted.
Maybe is/was was unavoidable, but it is not good to have spaces in field names.
It would really help to see the dB and all of the code, but here is what I see...
Code:
.
.
.
Case "ADD VALUE - Genesys"
'Check if file has already been imported
If DCount("Filename", "TBL_ADD_VALUE_Genesys_ImportedFiles", "Filename=""" & strFileName & """") = 0 Then
Dim sheetname1 As String '<<-- Declarations should be at the top of the routine, NOT within any looping structure.
' now have here problem with macro, need separate sheet name withouth format because now excel didnt understand which sheet need to take
sheetname1 = Left(strFileName, 19)
'sheetname1 = Left(strFileName, (Application.(".", strFileName, 1) - 1))
DoCmd.TransferSpreadsheet acImport, , "TBL_ADD_VALUE_Genesys-temp", strfolder & "" & strFileName, , sheetname1 '<<-- the RED text doesn't need to be there -
CurrentDb.Execute "INSERT INTO TBL_ADD_VALUE_Genesys_ImportedFiles (Filename) " & vbCrLf & _ '<<-- the vbCrLf shouldn't be there
"VALUES('" & strFileName & "')"
CurrentDb.Execute "APPEND_TBL_ADD_VALUE_Genesys"
CurrentDb.Execute "DELETE * FROM [TBL_ADD_VALUE_Genesys-temp]"
icounter_new = icounter_new + 1
strLastFileImported = strFileName
strLastFileImportedDate = Format(Now, "dd/MM/yyyy")
Else
icounter_existing = icounter_existing + 1
End If
.
.
.
Did you know "Example.csv" has a header row (field names), 1 row of data and 4657 lines of ";;;;;;;;;;;;;;;"?