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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top