Below is code that I'm working with that creates a link to a text file. The text file I'm working with is delimited with a ";". The first row of the text file is the field names and their delimited with a ";".
When I run the below code, it puts the entire text file into 1 field in the designated table.. I cannot figure out how to get this code so it shows the data the right way....
Any suggestions or examples...??
Thanks in advance,
jw5107
Sub LinkYTDRevCyclesTxtFile()
On Error GoTo Err_LinkYTDRevCyclesTxtFile
Dim Directory As String
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Set db = CurrentDb
Dim filename
filename = "YTDFltHist.txt"
Directory = GetPath(db.Name)
db.TableDefs.Delete "YTDFleetUtilizationMain"
Set tbl = db.CreateTableDef("YTDFleetUtilizationMain")
tbl.Connect = "Text;DATABASE=" & Directory & "; FMT=delimited;HDR=YES;IMEX=2"
tbl.SourceTableName = "YTDFltHist.txt"
db.TableDefs.Append tbl
db.Close
Exit_LinkYTDRevCyclesTxtFile:
Exit Sub
Err_LinkYTDRevCyclesTxtFile:
If Err.Number = 53 Then
Resume Next
ElseIf Err.Number = 3265 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_LinkYTDRevCyclesTxtFile
End If
End Sub
When I run the below code, it puts the entire text file into 1 field in the designated table.. I cannot figure out how to get this code so it shows the data the right way....
Any suggestions or examples...??
Thanks in advance,
jw5107
Sub LinkYTDRevCyclesTxtFile()
On Error GoTo Err_LinkYTDRevCyclesTxtFile
Dim Directory As String
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Set db = CurrentDb
Dim filename
filename = "YTDFltHist.txt"
Directory = GetPath(db.Name)
db.TableDefs.Delete "YTDFleetUtilizationMain"
Set tbl = db.CreateTableDef("YTDFleetUtilizationMain")
tbl.Connect = "Text;DATABASE=" & Directory & "; FMT=delimited;HDR=YES;IMEX=2"
tbl.SourceTableName = "YTDFltHist.txt"
db.TableDefs.Append tbl
db.Close
Exit_LinkYTDRevCyclesTxtFile:
Exit Sub
Err_LinkYTDRevCyclesTxtFile:
If Err.Number = 53 Then
Resume Next
ElseIf Err.Number = 3265 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_LinkYTDRevCyclesTxtFile
End If
End Sub