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
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