Hi,
I have a table of thousands of records in MS Access 2007. I want to export it to a text file consisting of 500 records per text file. I'm looking for a macro which can do this. The macro should ideally create the text files automatically.
I've gone as far as using the following code which works well to export the entire table into one text file. I don't know how to break up this big exported text file into smaller files of 500 records per file automatically during the import.
Thank you for your advice.
I have a table of thousands of records in MS Access 2007. I want to export it to a text file consisting of 500 records per text file. I'm looking for a macro which can do this. The macro should ideally create the text files automatically.
I've gone as far as using the following code which works well to export the entire table into one text file. I don't know how to break up this big exported text file into smaller files of 500 records per file automatically during the import.
Thank you for your advice.
Code:
Sub ExportToText()
Dim rst As DAO.Recordset
Open "C:\Users\a\Desktop\test.txt" For Output As #1
Set rst = CurrentDb.OpenRecordset("SELECT [Name] FROM [Australian Non Duplicate Names]", dbOpenSnapshot)
Do While Not rst.EOF
Print #1, rst!Name
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Close #1
End Sub