Public Function TableToText(tableName As String, textName As String) As Boolean
On Error Resume Next
Dim rst As Recordset, tbd As TableDef, colCount As Integer
For Each tbd In CurrentDb.TableDefs
If tbd.Name = tableName Then TableToText = True
Next
If TableToText = False Then Exit Function
Set rst = CurrentDb.OpenRecordset(tableName, dbOpenDynaset)
If rst.RecordCount Then
Kill textName
Open textName For Output As #1
For colCount = 0 To rst.Fields.Count - 2
Print #1, rst.Fields(colCount).Name; "|";
Next colCount
Print #1, rst.Fields(rst.Fields.Count - 1).Name
While Not rst.EOF
For colCount = 0 To rst.Fields.Count - 2
Print #1, rst.Fields(colCount).Value; "|";
Next colCount
Print #1, rst.Fields(rst.Fields.Count - 1).Value
rst.MoveNext
Wend
Close #1
End If
End Function