Hello,
I am confused on how once I have imported a file with the file path and name then be able to write code to export it back out to the same path and file name.
I will show you the code I have below:
Public Function GetFile() As Variant
Dim dialog As Object
Dim pickedfile As Boolean
Set dialog = Application.FileDialog(3)
GetFile = Null
With dialog
.InitialFileName = \\Hello\
.AllowMultiSelect = False
.Title = "Please select file for import"
.Filters.Clear
.Filters.Add "Text Files", "*.TXT; *.CSV"
pickedfile = False
pickedfile = .Show
If pickedfile Then
GetFile = .SelectedItems.Item(1)
End If
End With
End Function
And here is the import code
Dim Day1File As Variant
Dim Str As String
DoCmd.SetWarnings False
'Imports Daily Letter file you choose
Day1File = GetFile()
If IsNull(Day1File) Then
MsgBox "Nothing was selected", vbOKOnly
Else
Str = "DELETE * FROM Daily_Letters"
DoCmd.RunSQL (Str)
DoCmd.TransferText _
TransferType:=acImportFixed, _
SpecificationName:="DOC1", _
TableName:="Daily_Letters", _
FileName:=Day1File, _
HasFieldNames:=False
MsgBox "The Daily Letters File has been uploaded!"
End If
And this is what I tried using to export the file back out:
DoCmd.TransferText acExportFixed, "DOC1", _
"Daily_Letters", Day1File