formatting exported data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to export data from a single feild in a query to a text file separated
only by a semicollin, with no spaces and no returns.

thanks,
maurie
 
Public Sub TestSub()

Dim rst As ADODB.Recordset
Dim intFile As Integer
Dim NotFirst As Boolean

Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.Connection
rst.Open "qryTest"
intFile = FreeFile
Open CurrentProject.Path & "\output.txt" For Output As intFile

Do Until rst.EOF
If NotFirst Then
Print #intFile, ";";
Else
NotFirst = True
End If
Print #intFile, rst.Fields("FamilyName");
rst.MoveNext
Loop
rst.Close
Close intFile

End Sub

Where 'qryTest' is your query, and 'FamilyName' is the name of the field you
want to export, and 'output.txt' is the name of the file you want to export
to.
 
Back
Top