I found several things that needed correcting: a line continuation character was missing, the Flags parameter was set to open a file & the OpenFile parameter was set to open (not save) the file.
(I also renamed the file name variable.)
Try this:
Code:
Function Export()
On Error GoTo Export_Err
Dim strFilter As String
Dim strSaveAsFileName As String
Dim Fname As String
Fname = "UK" & TC_DATE!qry_TC_DATE
'qry and field name
'Ask for SaveAsFileName
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.TXT)", "*.TXT")
strSaveAsFileName = ahtCommonFileOpenSave( _
Filename:=Fname, _
Filter:=strFilter, _
OpenFile:=False, _
DialogTitle:="Please select a location to Export to", _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
If Len(strSaveAsFileName) > 0 Then
DoCmd.TransferText acExportFixed, "Export Specification", "05_qry_Export_final", strSaveAsFileName, False, ""
End If
Export_Exit:
Exit Function
Export_Err:
MsgBox Error$
Resume Export_Exit
End Function
If this line
Code:
Fname = "UK" & TC_DATE!qry_TC_DATE
creates the file name you want, then I think the code should save the file......