Input past End Of File

C

Chuck

Hello, I am trying to learn Access 2007 VBA and I am having a problem with
reading an input file. I get a runtime error 62, Input past EOF. Here is
the code I am using
Private Sub Command3_Click()
'Create variables to store the input fields
Dim lsPhoneNumber As String
Dim lsFirstName As String
Dim lsLastName As String

'Open the file for input into the listbox
Open "friends.dat" For Input As #1

'Use the Input function to retrieve fields from the file
Do Until EOF(1)
Input #1, lsPhoneNumber, lsFirstName, lsLastName
lstFriends.AddItem lsPhoneNumber & ", " & lsFirstName & ", " & lsLastName
Loop

Close 1

End Sub

The file is saved as a .dat file
"618-566-5859","Michael" "Jones"
"618-566-9876","Tom","Dixson"
"618-566-5732", "Rick", "Thompson"
"618-566-2343", "Charles", "Neeley"
 
S

Steve Rindsberg

Hello, I am trying to learn Access 2007 VBA and I am having a problem with
reading an input file. I get a runtime error 62, Input past EOF. Here is
the code I am using
Private Sub Command3_Click()
'Create variables to store the input fields
Dim lsPhoneNumber As String
Dim lsFirstName As String
Dim lsLastName As String

'Open the file for input into the listbox
Open "friends.dat" For Input As #1

'Use the Input function to retrieve fields from the file
Do Until EOF(1)

Replace that with this:

Do While Not EOF(1)
 

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