Rendering SQL As Excel Spreadsheet?

P

PeteCresswell

I've got some SQL that returns a RecordSet.

Instead of showing the RecordSet, I would like to create an Excel
spreadsheet based on said RecordSet.

No cosmetics, no beautification, no formatting; just a quick-and-dirty
spreadsheet.

Seems like Docmd.TransferText sb the vehicle, but I can't make it work
by feeding it SQL - only a table name.

I *know* I've done this in the past, but cannot recall how.

Or am I just wishing?
 
P

PeteCresswell

No cosmetics, no beautification, no formatting; just a quick-and-dirty
spreadsheet.

What I was really thinking was to do this without creating a recordset
based on the SQL, instantiating an instance of Excel, and looping
through the recordset, populating rows in the Excel instance's
workbook, saving the workbook, and so forth.
 
D

Damon Heron

How about this:

DoCmd.TransferSpreadsheet acExport, 8, "qrySumofPayments", "C:\NewXL.xls"

This transfers a saved query to an excel 2000 or newer spreadsheet.

Damon
 
J

Jeff Boyce

Consider the possibility of eliminating the MS Access step and simply doing
this from Excel itself, directly.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
P

PeteCresswell

DoCmd.TransferSpreadsheet acExport, 8, "qrySumofPayments", "C:\NewXL.xls"

That seems tb the ticket.

It even resolves query references to fields on forms - which is a
tripping point in other VBA approaches - like opening up a recordset
and iterating through it.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top