O
OJP
Hello,
I have spent several hours adapting code I found to import multiple txt files
into different tables. Despite all my efforts, I keep getting the following
error code eventhough the file is there.
Run Time error 3011
The Microsoft Jet Database Engine could not find the object ".
Make sure the object exists and that you spell it's name and path correctly
The problem resides on the line:
DoCmd.TransferText acImportDelim, strTable, strPathFile, ynFieldName
I know everything else works fine as I have stepped through it.
Any help will be appreciated.
Here is the code:
Public Sub Import()
On Error GoTo Err_F
Dim strPathFile As String
Dim strFile As String
Dim strPath As String
Dim strSpec As String
Dim strRight7 As String
Dim strTable As String
Dim ynFieldName As Boolean
ynFieldName = False
strPath = "H:\GFI_TVM_PEM_Translation\TestEnv\TVM\TXT\"
strSpec = "TVMImportSpecs" ' This is my saved import specification
strFile = Dir(strPath & "*.txt")
Do While Len(strFile) > 0
strRight7 = Right(strFile, 7) ' The last 3 digits determine which
table gets the data
Select Case strRight7
Case "101.txt"
strTable = "TVM101"
GoTo Import_Data
Case "102.txt"
strTable = "TVM102"
GoTo Import_Data
Case "103.txt"
strTable = "TVM103"
GoTo Import_Data
Case "104.txt"
strTable = "TVM104"
GoTo Import_Data
Case "105.txt"
strTable = "TVM105"
GoTo Import_Data
Case "106.txt"
strTable = "TVM106"
GoTo Import_Data
Case "107.txt"
strTable = "TVM107"
GoTo Import_Data
Case Else
Exit Sub
End Select
'strFile = Dir()
'Loop
Import_Data:
strPathFile = strPath & strFile
'(((((((
' The next line of code is the problem
')))))))
DoCmd.TransferText acImportDelim, strTable, strPathFile, ynFieldName
Name strPath & strFile As "H:\GFI_TVM_PEM_Translation\TestEnv\TVM\
Archive\TXT\" & strFile 'Move the files to the archive folder
strFile = Dir()
Loop
Exit_F:
Exit Sub
Err_F:
MsgBox Err.Number & " " & Err.Description
Resume Exit_F
End Sub
I have spent several hours adapting code I found to import multiple txt files
into different tables. Despite all my efforts, I keep getting the following
error code eventhough the file is there.
Run Time error 3011
The Microsoft Jet Database Engine could not find the object ".
Make sure the object exists and that you spell it's name and path correctly
The problem resides on the line:
DoCmd.TransferText acImportDelim, strTable, strPathFile, ynFieldName
I know everything else works fine as I have stepped through it.
Any help will be appreciated.
Here is the code:
Public Sub Import()
On Error GoTo Err_F
Dim strPathFile As String
Dim strFile As String
Dim strPath As String
Dim strSpec As String
Dim strRight7 As String
Dim strTable As String
Dim ynFieldName As Boolean
ynFieldName = False
strPath = "H:\GFI_TVM_PEM_Translation\TestEnv\TVM\TXT\"
strSpec = "TVMImportSpecs" ' This is my saved import specification
strFile = Dir(strPath & "*.txt")
Do While Len(strFile) > 0
strRight7 = Right(strFile, 7) ' The last 3 digits determine which
table gets the data
Select Case strRight7
Case "101.txt"
strTable = "TVM101"
GoTo Import_Data
Case "102.txt"
strTable = "TVM102"
GoTo Import_Data
Case "103.txt"
strTable = "TVM103"
GoTo Import_Data
Case "104.txt"
strTable = "TVM104"
GoTo Import_Data
Case "105.txt"
strTable = "TVM105"
GoTo Import_Data
Case "106.txt"
strTable = "TVM106"
GoTo Import_Data
Case "107.txt"
strTable = "TVM107"
GoTo Import_Data
Case Else
Exit Sub
End Select
'strFile = Dir()
'Loop
Import_Data:
strPathFile = strPath & strFile
'(((((((
' The next line of code is the problem
')))))))
DoCmd.TransferText acImportDelim, strTable, strPathFile, ynFieldName
Name strPath & strFile As "H:\GFI_TVM_PEM_Translation\TestEnv\TVM\
Archive\TXT\" & strFile 'Move the files to the archive folder
strFile = Dir()
Loop
Exit_F:
Exit Sub
Err_F:
MsgBox Err.Number & " " & Err.Description
Resume Exit_F
End Sub