I tried to copy a code that I found in this forum on how to auto import csv files into table, and something is wrong with my added code and an error message appear when im trying to run the code:
Runtime error: 3625
"The text file specification "0" does not exist. You cannot import, export and link using the specification."
I have day to day file to be imported into my table name "Tablogs"
****************
Private Sub Command0_Click()
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
Dim filename As String
Dim path As String
DoCmd.SetWarnings False
path = "c:\3difProject\csv files\"
'Loop through the folder & build file list
strFile = Dir(path & "*.csv")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list of files
For intFile = 1 To UBound(strFileList)
filename = path & strFileList(intFile)
DoCmd.TransferText , acImportDelim, "Tablogs", filename, True
Next intFile
DoCmd.SetWarnings True
End Sub
**************************
Please tell me how to create a "SPECIFICATION" i dont how to do it.
Something is wrong with red line. Please advise if i need to add code or the syntax might wrong.
Please help me.
Thanks,JE
Runtime error: 3625
"The text file specification "0" does not exist. You cannot import, export and link using the specification."
I have day to day file to be imported into my table name "Tablogs"
****************
Private Sub Command0_Click()
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
Dim filename As String
Dim path As String
DoCmd.SetWarnings False
path = "c:\3difProject\csv files\"
'Loop through the folder & build file list
strFile = Dir(path & "*.csv")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list of files
For intFile = 1 To UBound(strFileList)
filename = path & strFileList(intFile)
DoCmd.TransferText , acImportDelim, "Tablogs", filename, True
Next intFile
DoCmd.SetWarnings True
End Sub
**************************
Please tell me how to create a "SPECIFICATION" i dont how to do it.
Something is wrong with red line. Please advise if i need to add code or the syntax might wrong.
Please help me.
Thanks,JE
Last edited: