A family of Microsoft relational database management systems designed for ease of use.
Hi Lonely,
As Hans said, you will need a file name/path but you could also add the filename without a prompt using something like:
Dim strExpDirectory As String
Dim strfullname As String
Dim strPath As String
Dim strQry As String
strQry = "qrytest"
strExpDirectory = Application.CurrentProject.Path & ""
strfullname = strExpDirectory & Format(Date, "yyyy-mm-dd")
DoCmd.TransferSpreadsheet acExport, , strQry, strfullname, True
This will save the fie to the same directory as your access database with the file name as today's date.
If you want to also open the spreadsheet once it is exported then you could use:
Dim strExpDirectory As String
Dim strfullname As String
Dim strPath As String
Dim xlApp As Object
Dim strQry As String
strQry = "qrytest"
strExpDirectory = Application.CurrentProject.Path & ""
strfullname = strExpDirectory & Format(Date, "yyyy-mm-dd")
DoCmd.TransferSpreadsheet acExport, , strQry, strfullname, True
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open (strfullname)
xlApp.Visible = True
I've used today's date as the file name but you could just have something generic