Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV File Import Error

Status
Not open for further replies.

Dire

Technical User
Jun 1, 2005
4
US
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.

 
It sounds like something needs to be changed with your import spec.

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top