Analyze it with Excel

Hello,
I would like the ability to add this to a form on a button click. I know of the "output to" and the "transfer spreadsheet", but i have a form that is datasheet view with 3 subforms in datasheet view, and I would like it to export to excel with those subforms grouped in (with the plus sybols for expanding records... just like in datasheet view.
Any help is much appreciated.
Thanks
a260148Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

a260148Author Commented:
Another point to add is that my recordset has to many records to use "output to"... and i can't use transfer spreadsheet unless it's a table. It would be great if their was a docmd.menu item... etc for the "analyze it with Microsoft Excel".
Thanks
Rey Obrero (Capricorn1)Commented:
try this

Private Sub cmdAnalyze_Click()

CommandBars("Menu Bar").Controls("Tools").Controls("Office Links").Controls("Analyze It With Microsoft Office Excel").accDoDefaultAction

End Sub
a260148Author Commented:
run-time error 5 - invalid procedure call or agrument
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Rey Obrero (Capricorn1)Commented:

huh...

just tried it with the Northwind database Orders form and it is working.
a260148Author Commented:
i have the dbwindow hidden... think that may be it?
a260148Author Commented:
Ok, i unhid the window and it does give me the option now, but when I export... it only grabs the main form, which is just a few textboxes... i need it to grab the subforms and such??
Rey Obrero (Capricorn1)Commented:
check the record source of  your form, subform .

i believe it will only export to excel the record source of the form.

check the Northwind Orders form, the record source Orders Qry is the one being exported to excel
harfangCommented:
Hi,

> ... a docmd.menu item... etc for the "analyze it with Microsoft Excel".

it's: RunCommand acCmdOutputToExcel

However, it's not what you want. You either want the details from the current record from the main form, and all three subform datasheets, or even all records from the main form, each along their corresponding three subform datasheets. In any case, this will require a bit of programming.

First, use simple copy-.paste to create the speadsheet you want. Where do you want each subdatasheet data to appear: one below the other, side-by-side, on different worksheets? How do you intermix data from the main form with the data from the subforms, etc.

Once you have a clear vision of what you want to create, start programming the export function.

The basic source will be the recordsets of the form and subforms. The basic tool will be the .CopyFromRecordset method of the Excel.Range object. You can either copy an entire recordset at once, or just the current record, or any preset number of records.

Finally, for the cosmetics (the data grouping buttons) you can use Excel's macro recorder to generate templates of what you need to acheive.

I hope this helps.
(°v°)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.