Importing one line of tex with many rows but only 5 fields

  • Thread starter Thread starter Chubb
  • Start date Start date
C

Chubb

i am trying to import a txt file with just one line of
tex, but i want to break it dow in to different rows but
only 4 fields.
example
(date,time,serialnumber,size,date,time,serialnumber)
how do i make it go to the next row just by linking or
importing it
 
You can't.

All imports using wizards require "rectangular" data.
Each row of data is 1 record.

You can always open the file in code and process it manually.
Then you can do whatever you want.
==================================
Here is an outline to get you started:
==================================
Public Sub ImportFile(strPath As String)

Dim db As Database, rs As Recordset
Dim sLine As String, sTrimmed As String
Set db = CurrentDb
Set rs = db.OpenRecordset("TableName", dbOpenTable)

Open strPath For Input As #1

'Read a single line from an open sequential file and assign it to a String
variable.
Line Input #1, sLine
'Trim the leading blanks
sTrimmed = LTrim(sLine)

Do While Not EOF(1)
'read the next line of the file
Line Input #1, sLine
sTrimmed = LTrim(sLine)

'manipulate the string if necessary, then add it to the rs table.
If rs.BOF = True Then
rs.AddNew
Else
rs.Edit
End If
rs.Update
Loop
End Sub
 
I had a problem with this as well. I had to use following
to get it to work.

Dim db As DAO.Database, rs As DAO.Recordset

Hope this helps,
Shawna
 
This is usually a problem with your references.
A2000 and A2002 use ADO by default.
I think in A2003 they finally switched back to DAO by default.
Since you probably won' t use ADO, open a code module, Tools, References and
uncheck ADO then check
Microsoft DAO 3.6.

The code is only an sample outline - please don't cut and paste it and
expect it to work.
 
Back
Top