• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Transfertext Header Rows

Hello, I am creating a text file from a table using the following vba script but the field names/headers are not included.  Is there a way to include the headers in a transfertext.  I have them included in my SPEC.  Thank you.


Private Sub cmdFileExp_Click()
   Dim sysdat As Variant, mo As Variant, da As Variant, yyyy As Variant
    Dim fname As Variant, fexist As String
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryPeopleReport_Clnup" 'Delete query
    DoCmd.OpenQuery "qryPeopleReport_App" 'Append query

    sysdat = Now()
    mo = Month(sysdat)
    da = Day(sysdat)
    yyyy = Year(sysdat)
    fname = "H:\HR\BENEFITS\" & "payroll_" & yyyy & "-" & mo & "-" & da & ".txt"
    fexist = Dir(fname)
    If Len(fexist) <> 0 Then
    Kill fname
    End If

    MsgBox "All People Report information being exported to " & fname & ".", vbOKOnly
    DoCmd.TransferText acExportDelim, "qrypeoplerepexp", "tblPeopleReport", fname

    MsgBox "export complete.", vbOKOnly
    DoCmd.SetWarnings True

End Sub
1 Solution
Patrick MatthewsCommented:

DoCmd.TransferText acExportDelim, "qrypeoplerepexp", "tblPeopleReport", fname, True

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now