Importing From a Specific Row

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Hello,
I have a text file I'd like to import or link into ACCESS
but I do not want the import to start until the 62nd row.
I'm looking for an EXCEL like import where you can
specify what row the import should start at.


TIA
Jim
 
No can do using the wizard.

You need to write code.
Then you can process the file one line at a time.
Obviously, the first thing you would do is write a loop to skip the first 61
rows!

=====================================================

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
 
Joe,
This is far and away above any response I expected to
receive. Words cannot express my true gratitude.

Thank you Joe,

Jim
 
Back
Top