Hi Amika,
You can ex****t the results of an SQL statement by saving it as a
query.
Public Sub Ex****tingResultsOfAnSQLStatement()
Dim qd As DAO.QueryDef
Set qd = CurrentDb.CreateQueryDef("qryTem****ary Query", _
"select * from [tblSomeTable]")
DoCmd.TransferSpreadsheet acEx****t, acSpreadsheetTypeExcel9, qd.Name,
"C:\Temp\Output.xls", True
CurrentDb.QueryDefs.Delete qd.Name
Set qd = Nothing
End Sub
Clifford Bass
"Amika" wrote:
> I would like to call customised view and ex****t to excel file for
> users to use. However, users have the right to choose what field
> should be shown and what table should be included.
>
> Problem comes. Although I can compose the SQL in VBA, however, I
> cannot ex****t a excel file from a SQL statement or a recordset.
>
> Anyway I can do so? I cannot ex****t a query or a table because the
> query for users may different.


|