Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create text file from Access table with additional record

Status
Not open for further replies.

KellyStee

Technical User
Jul 30, 2001
106
US
I have a command button that will copy records from an Access table and put them in a text file. The problem is I need to add another line to the beginning of the text file with the date, approx. 200 spaces, and a carriage return line feed. I can create this record first, with "Open. . .For Append" but then when I use the DoCmd to copy all of the records over, the DoCmd command seems to overwrite the file with the first record. If I create the header record after the DoCmd, then the record is at the END of the file and I need it to be at the beginning. Please help!! This is the code I have so far:

Private Sub cmdExporttoDesktop_Click()
Dim strInput As String, strMsg As String, strFileName As String
strMsg = "File name:"
strInput = InputBox(Prompt:=strMsg, _
Title:="Save As", XPos:=2000, YPos:=2000)
strFileName = "C:\" & strInput & ".txt"
Open strFileName For Append As #1
Print #1, Format(Now, "mm/dd/yyyy") & " "
Close #1
DoCmd.TransferText acExportFixed, "Extract File Export Specification", "Extract File", strFileName, False, ""
MsgBox "Export completed successfully!", vbOKOnly, "File Exported"
End Sub

Thanks in advance!!!
Kelly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top