I have the following code running from a simple click event:
I am aware of the output to option but this one works as the user can manually adjust the filename and destination in and unbound field on the form.
My question is I dont want it to pick up a table but a Query instead and maybe with some simple formatting too.
How can this be achieved?
Code:
Private Sub btnWeeklyReport_Click()
On Error GoTo Do_Nothing
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "WeeklyReport", txtExportFile
MsgBox "The tables have been successfully exported to " & txtExportFile & "."
Exit Sub
Do_Nothing:
MsgBox "Export has failed. An error occurred or the user terminated the operation."
End Sub
I am aware of the output to option but this one works as the user can manually adjust the filename and destination in and unbound field on the form.
My question is I dont want it to pick up a table but a Query instead and maybe with some simple formatting too.
How can this be achieved?