Exporting Form Records to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I know that when you have a Form that display records, there is a "Analyze
With Excel" Toolbar that when you click on it, it exports the info to Excel.
I like the way this works.

However I now have a main Form that is unbound and have a subform on it that
has the data. When I now click on this Toolbar it exports the info from the
Main Form not the subform with the Records. I also tried adding these
Toolbars to the ShortCut Menu of the Subform and still when you click on it
there it exports the Main Form info.

How can I get it to work that it Exports the records from the subform.

Any help would be greatly apprecaited.

Thank you,
Jeff
 
Usually you have to create a the subform as a regular form first. Then on
your new form add a subform and choose the one that you just created. Add a
button and for the on click event, have the following code run:

DoCmd.OutputTo acOutputForm, "NameOfSubform", acFormatXLS,
"NameOfOutputFileDesired.xls", True

This should do the job.

I am having one specific problem though. On my main form I use checkboxes
to turn on and off the columnhidden property of the data columns in the
subform. When I run the export command only the intial columns that I have
viewable are exported. Is there any way to export exactly the columns that I
have choosen to have the columnhidden property set to false?

Any help is much appreciated.

Thanks
 
Hi Blake,

Thank you for your reply.

For your question couldnt you also use DoCmd.OutputTo to Output the subfrm
Record Source whether it be a Query or a Table. You can even create you own
Query including the Fields you want then use the DoCmd.OutputTo acOutputQuery
of the new Query Name.

DoCmd.OutputTo acOutputQuery
DoCmd.OutputTo acOutputTable

I hope this helps,
Jeff
 
Back
Top