Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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
0
a260148
Asked:
a260148
  • 4
  • 3
1 Solution
 
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
0
 
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
0
 
a260148Author Commented:
run-time error 5 - invalid procedure call or agrument
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
Rey Obrero (Capricorn1)Commented:

huh...

just tried it with the Northwind database Orders form and it is working.
0
 
a260148Author Commented:
i have the dbwindow hidden... think that may be it?
0
 
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??
0
 
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
0
 
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°)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now