Littlemalky
Board Regular
- Joined
- Jan 14, 2011
- Messages
- 223
So I found this code to use to export my query as a text file to a file location. It's awesome and efficient and fast, but it's structured as an "Append". I'm not familiar enough with this kind of code to know how to convert it over to just replace the file each time. I want to overwrite it with new contents, not append.
Does anyone know how to modify this?
Does anyone know how to modify this?
Code:
Private Sub btnEXPORT_TEXT_FILE_Click()
Dim rs As DAO.Recordset, strRec As String, j As Integer
Set rs = CurrentDb.OpenRecordset("UNION_ADDITIONS_ACCRUALS_LOAD_FILES")
Open "[URL="file://\\cobalt\public\SCC\CAPEX\Test\UNION_ADDITIONS_ACCRUALS_LOAD_FILES.txt"]...\Test\UNION_ADDITIONS_ACCRUALS_LOAD_FILES.txt[/URL]" For Append As #1
Do Until rs.EOF
For j = 1 To rs.Fields.Count - 1
If strRec = "" Then
strRec = rs(j) & vbTab
Else
strRec = strRec & rs(j) & vbTab
End If
Next
Print #1, strRec
rs.MoveNext
strRec = ""
Loop
Close #1
MsgBox "Export Complete!"
End Sub