VBA Move to first line of text file after EOF has been reached

Posted on 2009-05-26
Medium Priority
Last Modified: 2012-05-07
I am opening a .txt file from Access VBA.  I need to read through each row and gather values (I can do this successfully). However, I then need to begin at the start of the file and read through it again.  I cannot determine how to make the procedure return to the beginning of the file.  I have attached my code below.  Thanks!
Public Sub ImportEDI(ctl As IRibbonControl)
'Get current user
gstrUser = WinUserName
Source_Path = "M:\m2mdata\data01\EDI\Acclimate\142 Documents"
Destn_Path = "M:\m2mdata\data01\EDI\Acclimate\142 Documents\Archive\"
Set fsoSysObj = New Scripting.FileSystemObject
Set fdrNew = fsoSysObj.GetFolder(Source_Path)
'Loop through Acclimate directory to process all pending files
For Each f In fdrNew.Files
SourceFile = Source_Path & "\" & f.Name
Open SourceFile For Input As #1 Len = 100
    'Determine Trading Partner Identification
    Do While Not EOF(1)
        Line Input #1, TextLine
        varFields = Split(TextLine, "~", -1, vbTextCompare)
        Select Case varFields(0)
            Case "ISA"
                strEDIID = Trim$(varFields(6))
            Case "GS"
                 strGroupID = Trim$(varFields(2))
        End Select
'This is where I need to move back to the first line of the input file
    'Call Procedure Based on ISA and Group ID
'DoCmd.Hourglass False
DoCmd.Echo True
End Sub

Open in new window

Question by:mizveggie
LVL 10

Accepted Solution

dwe761 earned 2000 total points
ID: 24473862

Author Closing Comment

ID: 31585298
that was perfect - wish i could have found it on my own!  thanks!

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question