Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a button to automatically export report to word.

Status
Not open for further replies.

Juddy58

Technical User
Jan 21, 2003
176
AU
Hello, Out of curiosity im trying to automate the task of exporting my access report into word, basically i want a button on a form that automatically opens the report and convets it to word format, instead of having to open the report in access and then using the office links function. Just wondering if this is possible, any help would be appreciated, thanks!
 
check out help on OutputTo method
put this in the OnClick event of your button:

Code:
DoCmd.OutputTo acOutputReport, "Test", acFormatRTF, "C:\Test.doc", True

the last 'true' is for 'autostart' meaning Word will then launch right after it saves.

i think the best format available is RTF, but name it '.doc' so it launches with Word.
 
Thanks for the help Gigger R, Just one question though
I have managed to get it working the only thing is that all records come out in the report, is it possible to transfer only the current record displayed in the form over to the report in word?
Once again thanks for the help!
 
dont worry silly me managed to work it out!
Thanks
 
Iam tyrying to do the exact same thing, but haven't worked out how to output only the one report that I have selected in my from. Could you shed any light on this for me. Cheers
 
Here is how i did it, sorry if the explanation isnt the best,
go into the record source for the report, and in the criteria for the distinguishing field for the report, right click and select build then click on forms and select the form in which you will open the report from, you then have to double click on the appropriate text box with in that form. This textbox will then become the criteria.
.for example mine is a quote report, i have a form where users input quotes, there is a text box for the quote number in this form. this quote number text box is the criteria in my report query. The report will now only open when the related form is open other wise there will be no criteria in the query.
Sorry if this explanation isn't the best, if you have any difficulties just post again and i will try to explain better.
 
Juddy, thank you for your advice. Unfortunately, my report is already bound to a table, and here is where it gets confusing, because it is bound to a different table than the report it is opened from is. If you understand my meaning.

Therefore the record scource for the report already has stuff in. The thing is that I inherited this software development from someone else, and probably wouldn't have chose to do it this way myself, but never mind.

Any way. I have since managed to achieve my goal, but what is probably a rather a crude method. If I open the report using
Docmd.openreport, I can use the wherecondition to bring up the exact report I need. If I then use The
Docmd.outputto, method described by Ginger above, and immediately close the report again, I get the desired affect in three lines of code.

It's also worth noting that the user would not see the report open and close quickly, as the form is pop-up modal, so always hides it.

If you would like to make any further coments on my slightly caggy handed approach then please feel free.

Again thank you for your comments.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top