All,
I have limited experience with VBA but have used it in the past.
I am currently trying to set up a module within access so that I can read the current files of the directory (.txt files) and then bring them into a database using "TransferText". I am running into one issue when using this command.
------------------------This code works:------------------------
Sub Test()
Dim file_name As String
Dim strPath As String
strPath = CurDir & "\" & "*.txt"
strFile = Dir(strPath)
'file_name = CurDir & "\" & strFile
file_name = "C:\Access_Database_Process\POLL_Output_2010_06_08_14_09_16.txt"
DoCmd.TransferText acImportDelim, "Import_ Specification", "NC_Haul_Opt_Table", file_name
End Sub
---------------------------------------------------------------------
------------------------This code doesnt work:------------------------
Sub Test()
Dim file_name As String
Dim strPath As String
strPath = CurDir & "\" & "*.txt"
strFile = Dir(strPath)
file_name = CurDir & "\" & strFile
'file_name = "C:\Access_Database_Process\POLL_Output_2010_06_08_14_09_16.txt"
DoCmd.TransferText acImportDelim, "Import_ Specification", "NC_Haul_Opt_Table", file_name
End Sub
---------------------------------------------------------------------
I have verified that the file name with path is being generated correctly for the code "that doesnt work" but I still receive an error stating "run time error 31519: you can not import this file"
What am I missing here?
Thanks.
I have limited experience with VBA but have used it in the past.
I am currently trying to set up a module within access so that I can read the current files of the directory (.txt files) and then bring them into a database using "TransferText". I am running into one issue when using this command.
------------------------This code works:------------------------
Sub Test()
Dim file_name As String
Dim strPath As String
strPath = CurDir & "\" & "*.txt"
strFile = Dir(strPath)
'file_name = CurDir & "\" & strFile
file_name = "C:\Access_Database_Process\POLL_Output_2010_06_08_14_09_16.txt"
DoCmd.TransferText acImportDelim, "Import_ Specification", "NC_Haul_Opt_Table", file_name
End Sub
---------------------------------------------------------------------
------------------------This code doesnt work:------------------------
Sub Test()
Dim file_name As String
Dim strPath As String
strPath = CurDir & "\" & "*.txt"
strFile = Dir(strPath)
file_name = CurDir & "\" & strFile
'file_name = "C:\Access_Database_Process\POLL_Output_2010_06_08_14_09_16.txt"
DoCmd.TransferText acImportDelim, "Import_ Specification", "NC_Haul_Opt_Table", file_name
End Sub
---------------------------------------------------------------------
I have verified that the file name with path is being generated correctly for the code "that doesnt work" but I still receive an error stating "run time error 31519: you can not import this file"
What am I missing here?
Thanks.