Hello everyone,
I am trying to get some code to work and am not having much luck. I keep getting a Jet error 3011 saying that it can't find the file "ppab0379.4837.txt". I know that the file exists just as it is above. Any help would be appreciated.
I am trying to get some code to work and am not having much luck. I keep getting a Jet error 3011 saying that it can't find the file "ppab0379.4837.txt". I know that the file exists just as it is above. Any help would be appreciated.
Code:
Private Sub bImportFiles_Click()
On Error GoTo bImportFiles_Click_Err
Dim strImportFile As String, strTableName As String
Dim strfile As String
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFolderPath As String
strFileExt = ".txt"
strTableName = "TblDailyFiles"
strImportFile = Dir(strFolderPath & "\*" & strFileExt)
strfile = strFolderPath & strImportFile
strFolderPath = "C:\Documents and Settings\parkes23\My Documents\Daily Recon\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If Right(objF1.Name, 3) = "txt" Then
DoCmd.TransferText acImportDelim, "TxtImportSpec", strTableName, strfile
End If
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
bImportFiles_Click_Exit:
Exit Sub
bImportFiles_Click_Err:
MsgBox Err.Number & " " & Err.Description
Resume bImportFiles_Click_Exit
End Sub
[Code]
Thanks,
PROXI