Can someone help me with this error?
Runtime Error "3061"
Too Few Parameters. Expected 1.
The debug goes to the red text below... my data loads to the table fine though.
Sub ImportData()
Dim sFileDir As String
Dim fs
Dim fsFolder
Dim fsFile
Dim sFileName
Dim db As Database
Dim sSQL As String
Set db = CurrentDb
Set fs = CreateObject("Scripting.filesystemobject")
sFileDir = CurrentProject.Path & "\"
Set fsFolder = fs.getfolder(sFileDir)
For Each fsFile In fsFolder.files
sFileName = fsFile.Name
If Len(sFileName) = 11 Then
If IsNumeric(Left(sFileName, 6)) Then
If Right(sFileName, 5) = ".xlsx" Then
Debug.Print sFileName
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tblImportedData", sFileDir & sFileName, True
sSQL = "UPDATE tblImportedData SET OriginalFilename = '" & Left(sFileName, 6) & "' WHERE (isnull(OriginalFilename))"
db.Execute sSQL
End If
End If
End If
Next
Set fs = Nothing
Set db = Nothing
End Sub