I recommend against using the FileSystemObject, as apparently this uses,
because many System Administrators ensure that the scripting runtime (of
which it is part) is disabled on all machines in their domain. They view it,
primarily, as the vehicle by which many viruses and worms are spread. Some
even include "search and destroy" software in the startup sequence in case
some "rogue application" has reinstalled it.
When it comes to reading and writing, you can do every thing with the
traditional builtin File I/O statements that can be done with the
FileSystemObject.
The following reads a name and address file and stores the data in a table.
It could just as well have used the Print # command to write the data to
another text file. You'll need to make certain the DAO reference is set, if
you use similar code to write to a table in the database.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strLine As String
Dim intFn As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPeople", dbOpenDynaset)
intFn = FreeFile
Open pstrFile For Input Access Read As intFn
Do While EOF(intFn) = False
Line Input #intFn, strLine
rs.AddNew
rs("PersonName") = Trim(strLine)
Line Input #intFn, strLine
rs("PersonStreet") = Trim(strLine)
Line Input #intFn, strLine
rs("PersonCityST") = Trim(strLine)
Line Input #intFn, strLine
rs("PersonZIP") = Trim(strLine)
Line Input #intFn, strLine
rs("PersonPhone") = Trim(strLine)
Line Input #intFn, strLine
rs("PersonFax") = Trim(strLine)
rs.Update
Loop
rs.Close
Close intFn
Set rs = Nothing
Set db = Nothing
Larry Linson
Microsoft Access MVP