Last updated: before December, 1998
'The purpose of this script is to create an delimited text file from 2 fields 'in a database. Field_1 is a text value to output in every record. Field_2 is 'a grouping field. Many records with similiar attributes can be this value. 'The database is sorted by Field_2 prior to Script execution. This script is 'used to export invoice transactions to a mainframe Cost of Sales and Cost of 'Production application. The mainframe input format requires a batch header '(Field_2) to preceed each group of detail records (Field_1). In my App 'Field_1 and Field_2 are calculated fields. I'm testing another variety of 'this as an audit trail or event log on users activity. Sub Click(Source As Button, X As Long, Y As Long, Flags As Long) Dim fileNum As Integer, I As Integer Dim N As Long Dim fileName As String, many_rec As String, few_rec As String, inv_test As String fileNum% = Freefile() fileName$ = Curdrive () +"\WINDOWS\TEMP\DATA.TXT" N=CurrentWindow.NumRecordsFound many_rec$=Source.Field_1.Text ' Field_1 is an Object name for detail text string to output few_rec$=Source.Field_2.Text batch_test$=Source.Field_2.Text ' Field_2 is an Object name for batch section text string to output ' Write out the data. Open fileName$ For Output As fileNum% Write #fileNum%, few_rec$ Write #fileNum%, many_rec$ ' Writes First records information I%=I%+1 Do While I%<= N CurrentApplication.ActiveDocWindow.NextRecord I%=I%+1 many_rec$=Source.Field_1.Text few_rec$=Source.Field_2.Text If few_rec$<>batch_test$ Then Gosub ResetHeader Write #fileNum%, many_rec Loop Close fileNum% Goto Skip ResetHeader: Write #fileNum%, few_rec$ section_test$=Source.Field_2.Text Return Skip: End Sub 'Written by Jerry Sikes <Unisource Converting>, 1996 '(C) Copyright 1996 by Jerry Sikes ' 'Permission is granted to freely copy this script in electronic form, 'or to print for personal use. It may be use in any Approach database, 'but may not be distributed for profit either by itself or as part of 'a collection or database. ' 'Disclaimer: This script is provided as is without any express or 'implied warranties. The author assumes no responsibility for errors or 'omissions, or for damages resulting from the use of the information contained 'herein, or your own version containing your desires for the usage of the 'script.