Importing From a Specific Row

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
 
J

Joe Fallon

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
 
J

Jim

Joe,
This is far and away above any response I expected to
receive. Words cannot express my true gratitude.

Thank you Joe,

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top