Hi Rich,
I know it works fine with ADODB but I'm using DAO in my application.
My aim was to simply pass a DAO RecordSet to a sub that would export the
content of the recordset to Excel.
I know I can export queries and form content to Excel using 'DoCmd.
TransferSpreadsheet' or 'DoCmd.OutputTo', but in my case I'm trying to export
a subform in datasheet mode whose RecordSource is modified in code. The
purpose of this was to export the data viewed by the user to a spreadsheet.
Turns out it's a lot harder than I expected in my case as:
- I'm not using a named query but a SQL statement that I modify on the fly,
so I cannot pass it to the DoCmd methods as they expect named queries.
- my SQL statement is based on another query that is dependent on the value
of a combobox on the main form, and it seems that using ADODB doesn't
correctly interpret that (it keeps generating an error saying that a
parameter value hasn't been provided, even though it works fine in DAO).
- the data I want to export being on a subform, 'DoCmd.outputTo acForm' only
exports the main form, not the subform. I even tried to get a fully qualified
name for the subform to no avail: it only wants a form name, not the name of
a form instance.
Instead, I'll have to reinvent the wheel and code a sub that will take a
form's reference and output an excel file matching the form's datasheet
layout.
That's Access and VBA for me... ;-(
--
--
Renaud Bompuis
http://blog.nkadesign.com http://etc/nkadesign.com
Message posted via
http://www.accessmonster.com