Hi, I was wondering if anybody can help with this problem.
I currently have a txt file with data listed similar to that below. What I am trying to do is create an output txt file which will list only specific criteria which is requested. For example just "cpntcs" which have played "Lin02" only.
The code will skip through the input file and produce an output file with just "cpntcs" and "lin02" directly underneath.

cpntcs0835..........
Lin01
Lin02
Lin03
Lin04
cpnlpl0835............
Lin01
Lin02
cpnptc0835..........
Lin02
Lin04
Cpnptp0835..........
Lin01
Cpnptp0835..........
Lin04


I have based my code on a previous VBA module which i have used which adds "000" into the "cpntcs" line only. As I mention this has been amended to what "I" think the VBA coding should like.

I am awareb that there are possibly many ways to do this, but I am only interested in using it In VBA in Access.

The module looks like this :

Function inputtooutputhandle(infile As String, outfile As String)

Dim InputHandle As Integer
Dim OutputHandle As Integer
Dim InfileHandle As String
Dim OutfileHandle As String

InputHandle = FreeFile
Open infile For Input As #InputHandle
OutputHandle = FreeFile
Open outfile For Output As #OutputHandle
Do While EOF(InfileHandle)
If Left(InfileHandle, 6) = "CPNTCS" Then
InputHandle = OutfileHandle
Else
OutputHandle = InputHandle
End If
Print #InputHandle, OutfileHandle
Loop
Close #OutputHandle
Close #InputHandle
End Function

Thanks