hi -
here is a brief description of the issues that i am running across.
i am using the following code to import .CSV files in my database.
===============================================
Public Function pfImport()
On Error GoTo Err_F
Dim fso As Object, fol As Object, fils As Object, f As Object
Dim strPathFile As String, strFile As String, strPath As String, strSpec As String
Dim strTable As String, ynFieldName As Boolean
' use ynFieldName to tell TransferText whether .csv file has field names (True) Or Not (False)
ynFieldName = False
' strPath is the path to the folder in which the files will be placed - use your names
strPath = "C:\RTR Temp\Daily_Reports\"
' strSpec is name of import specification
strSpec = "Import_Specifications2"
'strTable is name of table to which file is to be imported
strTable = "Temp_Tbl"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder(strPath)
Set fils = fol.Files
For Each f In fils
' checks all files in the folder specified above
If Right(f.Name, 4) = ".csv" Then
' found a ".csv" file
strPathFile = strPath & f.Name
' set entire path&file name
' import .csv file
DoCmd.TransferText acImportDelim, strSpec, strTable, strPathFile, ynFieldName
' delete the file that was just imported (leave out this step if you want to manually delete the file)
f.Delete
End If
Next f
Exit_F:
Set f = Nothing
Set fils = Nothing
Set fol = Nothing
Set fso = Nothing
Exit Function
Err_F:
MsgBox Err.Number & " " & Err.Description
Resume Exit_F
End Function
===============================================
this code was working fine while i was using the "test" CSV file to import. now that i am using the "real" CSV file, the data is not being imported completely (some columns from the CSV file are being skipped while in other columns some data is being skipped).
i would like to ensure that all the data from the CSV file is being imported.
any help is appreciated.
thanks.
here is a brief description of the issues that i am running across.
i am using the following code to import .CSV files in my database.
===============================================
Public Function pfImport()
On Error GoTo Err_F
Dim fso As Object, fol As Object, fils As Object, f As Object
Dim strPathFile As String, strFile As String, strPath As String, strSpec As String
Dim strTable As String, ynFieldName As Boolean
' use ynFieldName to tell TransferText whether .csv file has field names (True) Or Not (False)
ynFieldName = False
' strPath is the path to the folder in which the files will be placed - use your names
strPath = "C:\RTR Temp\Daily_Reports\"
' strSpec is name of import specification
strSpec = "Import_Specifications2"
'strTable is name of table to which file is to be imported
strTable = "Temp_Tbl"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder(strPath)
Set fils = fol.Files
For Each f In fils
' checks all files in the folder specified above
If Right(f.Name, 4) = ".csv" Then
' found a ".csv" file
strPathFile = strPath & f.Name
' set entire path&file name
' import .csv file
DoCmd.TransferText acImportDelim, strSpec, strTable, strPathFile, ynFieldName
' delete the file that was just imported (leave out this step if you want to manually delete the file)
f.Delete
End If
Next f
Exit_F:
Set f = Nothing
Set fils = Nothing
Set fol = Nothing
Set fso = Nothing
Exit Function
Err_F:
MsgBox Err.Number & " " & Err.Description
Resume Exit_F
End Function
===============================================
this code was working fine while i was using the "test" CSV file to import. now that i am using the "real" CSV file, the data is not being imported completely (some columns from the CSV file are being skipped while in other columns some data is being skipped).
i would like to ensure that all the data from the CSV file is being imported.
any help is appreciated.
thanks.