1 Attachment(s)
Importing a *.txt file to a Access database
I have attached a file which I exported from a access database. Now I need to find a way of importing that table again?.I am able to create a blank table with the right fields in place, for the *txt file I just need to beable to import the data. Anyone know how??
Here isa what I got so far
Quote:
Originally posted by BrandonSk
Peet's code is OK.
I still would use ISAM drivers though. If nothing else it is much faster (depends on your txt file size, my was 0.5GB!)
This is what I have got so far, I will have a look at those websites you got, but have a look at this and see if you know how to complete it. Thanks
Private Sub cmdImport_Click()
Dim sFName As String
Dim sFmtsFName As String
'On Error GoTo ErrHandler
CommonDialog1.Filter = "Tempcontrol Files (*.*)|*.*"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
OpenFile = ("CommonDialog1.FileName")
sFName = CommonDialog1.FileTitle
With dePenlogs.cnlogs
If .State = 0 Then
.Open
End If
.BeginTrans
.Execute "CREATE TABLE " + sFName + "(" _
& "LogNo CHAR (20) NULL," _
& "Duration CHAR(20) NULL," _
& "Time_s CHAR(20) NULL," _
& "Value_s CHAR(20) NULL);"
.Execute "INSERT INTO " + sFName + "(LogNo, Duration, Time_s, Value_s)" _
& "VALUES()"
.CommitTrans
End With
Exit Sub