Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export to spreadsheet, how to use recordset or query 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I've got my query string working, and I would like to use the query to export records as a spreadsheet.

The problem I am having is it seems the
Code:
DoCmd.TransferSpreadsheet acExport,
command is expecting a tablename to be supplied, yet I want to use a sql select statement or recordset and it keeps erroring if I use either.

Is it possible to do an export to spreadsheet using another datasource other than a table?

or if not is there an easy way to create a table on the fly based on a sql select statement or recordset that I could then issue the transferspreadsheet against then delete?

Advice on the best approach is appreciated.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
That gave me an idea, thanks JerryKlmns, I did this...
Code:
DoCmd.DeleteObject acQuery, "Export_Prospects"

CurrentDb.CreateQueryDef "Export_Prospects", sSQL

then as you say supplied the query name for the export, works like a dream.

Many thanks 1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top