Access 2007.
I'm going through someone else's database, and I'm seeing they import a few .txt and.csv files (some delimited, some fixed). They use the line:
docmd.transfertext acimportdelimited, "xxx", ...
Where "xxx" is the [specificationname]. I have looked in the saved imports and cannot find "xxx". Where else might this instruction be? There are about a dozen imports and they all have their own [specificationname]. I'm rewriting their code in a new db and I need my process to match theirs.
My code so far below:
Code:Sub test() Dim rst As DAO.Recordset Dim sFileName As String 'Set variables Set rst = CurrentDb.OpenRecordset("SELECT * FROM t_BklgFileLocation") 'Check if table contains records If Not (rst.BOF And rst.EOF) Then 'Move to first record rst.MoveFirst 'Loop through each record Do Until rst.EOF = True 'If the table currently exists, delete it On Error Resume Next DoCmd.RunSQL "DROP TABLE " & rst("TableName") On Error GoTo 0 'Set variable sFileName = rst("FileLocation") & "\" & rst("FileName") 'Import new table 'On Error Resume Next Debug.Print rst("TransferType") If rst("TransferType") = "acImportFixed" Then DoCmd.TransferText acImportFixed, , rst("TableName"), sFileName 'THIS IS WHERE I"M TRYING TO FIX End If 'On Error GoTo 0 'Delete ImportErrors table On Error Resume Next DoCmd.DeleteObject acTable, rst("TableName") & "_ImportErrors" On Error GoTo 0 'Move to the next record 'Without this line, there would be an endless loop rst.MoveNext Loop Else: 'Tell user there are no records MsgBox "There are no records in this recordset", vbOKOnly, "Error" End If 'Close the recordset rst.Close 'Clear memory Set rst = Nothing End Sub


Reply With Quote


