TransferText acImportDelim takes abnormal amount of time.

F

felice.tecce

I am trying to import data from a text file (*.txt) which happens to be comma
delimitted. I am using the DoCmd.TransferText with a pre-defined Import
Specification. It seems to work fine (time-wise, speedy) the first time
around. When I perform the same action the second time around, it takes
forever. And eventually finishes error free. Any suggestions?


In the code below rstPaths!Path will give the path (including file name) to
the file being imported.
And the problem described above is occuring in Case#1 of the Select...Case
below.

Public Sub ImportFile(ByRef tbl As TableDef, ByRef FileTYP As FLTypes,
Optional ByVal Append As Boolean = False)
'Use the tbl.Name for the following:
'rstPath!Name
'[SPEC-NAME]
'[Range]
Set rstPaths = CurrentDb.OpenRecordset("FilePaths", dbOpenDynaset)
rstPaths.FindFirst "Name='" & tbl.Name & "'"
'If Append = False Then ClearTableContents (tbl.Name)


Select Case FileTYP
Case 0 'Excel File
'DoCmd.TransferSpreadsheet TransferType, SpreadsheetType, TableName,
FileName, HasFieldNames, Range
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, tbl.Name,
rstPaths!Path, True, tbl.Name
Case 1 'Text File
'DoCmd.TransferText TransferType, SpecificationName, TableName,
FileName, HasFieldNames
DoCmd.TransferText acImportDelim, tbl.Name, tbl.Name, rstPaths!Path,
True
Case 2 'CSV File
'DoCmd.TransferText TransferType, SpecificationName, TableName,
FileName, HasFieldNames
DoCmd.TransferText acImportDelim, tbl.Name, tbl.Name, rstPaths!Path,
True
Case Else 'Non of the above
'Error an appropriate filetype was not passed.
End Select

Set rstPaths = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top