I need to create a data file called students.dat and insert a few records into it.

I need (3) fields: 1) student id no. 2) last name 3) first name

I thought it would be pretty straight forward, but I get a compile error: Invalid Outside Procedure and "students.dat" is highlighted. Can anyone help me out on this? Thanks in advance.

Here is my code thus far.

Option Compare Database
Option Explicit

' Create Students Data file

Open "students.dat" For Output As #1

Write #1, "123-00", "Joan", "Blake"
Write #2, "560-05", "Mary", "Smith"

Close 2

After some persistence, I was able to create/insert records to the data file.

But, I'm not having any luck with the 2nd part of my assignment, which is to create a form permitting a user to view all records in the data file via populating records to a list box. I also have to use error handling when opening the data file.

Can anyone get me started in the right direction for this added task? I've added a button and list box to a form, but can't get the records to load...

Any assistance is greatly appreciated.

Solved this one on my own. Thanks anyway. It took me all night, but it's worth it when it works!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.