By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

How to send form contents to MS Excel?

P: 13
Hi guys,

I have a tabular form that contains header section and detail section. The header section is used for searching and applying filters. The header section is not bound to any table in the database. Basically, users can enter their search criteria in the header section and see results in the details section.

How can I send the results (so only the fields from details section) to MS Excel? I can't use DoCmd.TransferSpreadsheet, because this method can only be based on a table or a query and not on a form. When I use OutputTo method it sends to Excel also the contents of the header section, which I absolutely don't want.

Thanks for any help!
Jan 3 '08 #1
Share this Question
Share on Google+
5 Replies


jaxjagfan
Expert 100+
P: 254
Hi guys,

I have a tabular form that contains header section and detail section. The header section is used for searching and applying filters. The header section is not bound to any table in the database. Basically, users can enter their search criteria in the header section and see results in the details section.

How can I send the results (so only the fields from details section) to MS Excel? I can't use DoCmd.TransferSpreadsheet, because this method can only be based on a table or a query and not on a form. When I use OutputTo method it sends to Excel also the contents of the header section, which I absolutely don't want.

Thanks for any help!
Make a query that uses your header as its criteria and then use the TransferSpreadsheet method to export the query.
Jan 3 '08 #2

P: 13
Make a query that uses your header as its criteria and then use the TransferSpreadsheet method to export the query.
Thanks, but some of the fields in the header are using filters. How do I use filters in a query?
Jan 3 '08 #3

jaxjagfan
Expert 100+
P: 254
Thanks, but some of the fields in the header are using filters. How do I use filters in a query?
What type of controls are you using in the header (TextBoxes, ComboBoxes, ToggleButtons, CheckBoxes, etc)? What are the names of these controls? What is your data table name and field names?

A simplistic view of possible SQL.
Select MyTable1.MyField1 from MyTable1 Where MyField1 = [txtHeader1];

If you use the QBE grid to build you query and use the builder and select forms. It will display the names of your controls to choose from. In my sample above I would have had a textbox control named "txtHeader1".
Jan 3 '08 #4

P: 13
Thanks for your reply, jaxjagfan.
All controls in my header are text boxes. Some of them contain texts, some numbers and some dates.
I see one problem with the query that you posted. Not all search criteria fields are always filled in. What if txtHeader1 is empty and only txtHeader2 is filled in? The query will not work...
Jan 3 '08 #5

P: 13
Why is it so complicate? Isn't it possible to just send the current recordset of the form after the users have chosen their search criteria?
Jan 4 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.