It sounds to me like your goal is to populate a database with data.
What you seem to be asking is to have a text file that is essentially a series of insert statements, one for each record.
I'm guessing. But I think that once Brian gets beyond being annoyed at your typing skills, he'll tell you to store the data in a text file or Excel file, link to that file using a Linked table in Access and just build an Append query from the linked table to your database table. Of course you'll need to do this for each table. And you'll have to populate related tables in the right order.
I'm sure somebody out there will say this is an ideal situation for a macro. (Is that mmcdonal that would say that?) At any rate, once you get your files linked as tables and your append queries built, just create a macro that will run the queries in the right order.
I can understand why you desire a text file to have all the Insert Into statements for each record. But that will take a lot longer to build than the technique mentioned above.
But if that's what you want to do, it's not that difficult. You'll simply write a routine that opens a text file for output, then opens a record set on your table. Step through each record in the record set and write a line in the text file with the Insert statement. Something like,
INSERT INTO Table1 ( Field1, Field2 ) SELECT "Test" AS Expr1, "Test" AS Expr2 FROM Table1;
You can use some techniques to more easily build the insert statement. Like:
' This builds the list of fields to insert into
For each field in recordset
strIntoList = strIntoList & field.name & ", "
next field
' This builds the values for the select
For each field in recordset
strSelectValues = strSelectValues & recordset(field.name).value & ", "
next field
You'll have to do things like add quotes (") for text strings and hash marks (#) for dates. Sorry, I'm not going to write all of the code for you. I generally get paid to do that. But that should start you on the right track.
Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org