OutputTo Method. Now, previously pre Office , the basic format to export a query to Excel format was simply:. So your code would thus become:. Nothing could be easier! Such as:.
|Country:||United Arab Emirates|
|Published (Last):||23 August 2014|
|PDF File Size:||3.62 Mb|
|ePub File Size:||4.81 Mb|
|Price:||Free* [*Free Regsitration Required]|
Log In. Thank you for helping keep Tek-Tips Forums free from inappropriate posts. The Tek-Tips staff will check this out and take appropriate action. Click Here to join Tek-Tips and talk with other members! Already a Member? Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free. Register now while it's still free! Already a member? Close this window and log in. Join Tek-Tips Forums! Join Us! By joining you are opting in to receive e-mail. Promoting, selling, recruiting, coursework and thesis posting is forbidden. Students Click Here. I have the following code on a button. I cannot figure out why I get a Type Mismatch error message when I try it.
Can anyone see what is wrong with what I have here? I am just trying to save a report to PDF in the specified file. Eventually I am going to want it to take textbox values from the report as the name of the PDF when it is saved. But I cannot get this to even work.
Try using this DoCmd. Does your code compile? Do you have Option Explicit in the code header? I don't see where you Dim TheMessage.
Which line causes the error? Thanks for helping! I tried PaulF's code but receive the following message: "The Object Type argument for the action or method is blank or invalid. As for dhookom's question - yes, it does compile but no, I do not have Option Explicit in the header. And I do not know which line causes the error as it only shows the type mismatch message box and does not revert to the code window and the code line causing the error. Thanks dhookum - I tried what you suggested but I am still getting the same "Type Mismatch" message.
The code seems to stop after the print preview of the report at which time the error message appears I can see the preview of the report behind the message.
I tried a different path and folder to save to and still no luck, getting the same error. Can you open the report and preview all of it? Did you add Option Explicit? If not, then do it and check out FAQ How to debug your code. I made a typo.. I used strDocName instead of stDocName, change that and it should work.
Thanks again for helping. I fixed the part you mentioned PaulF. I have no idea where it is going. I even placed a msg box at the end to pop up when the code is finished. The message box pops up as if it should all be working properly. And dhookom - I did as you mentioned after researching the importance of Option Explicit I am self-taught and constantly learning even fundamental things.
However it seems like the code should work. It still comes up with the "type mismatch" message. That did it - it works perfectly now! Thank you very much - I appreciate your patience with my very limited knowledge. I see what you did and it makes sense to me now. Thanks again! Red Flag This Post Please let us know here why this post is inappropriate.
Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework. Close Box. Students Click Here Join Us!
Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.
DoCmd.OutputTo in xlsx (Excel 2007+) Format
You can use the OutputTo method to output the data in the specified Access database object a datasheet, form, report, module, data access page to several output formats. The Access data is output in the selected format and can be read by any application that uses the same format. For example, you can output an Access report with its formatting to a rich-text format document and then open the document in Microsoft Word. The following code example outputs the Employees table in rich-text format. Have questions or feedback about Office VBA or this documentation?
DoCmd.OutputTo method (Access)
Log In. Thank you for helping keep Tek-Tips Forums free from inappropriate posts. The Tek-Tips staff will check this out and take appropriate action. Click Here to join Tek-Tips and talk with other members!
Linking Criteria in "OutputTo" Method
OutputTo -Method. There is one aspect of using this very convenient method that I frequently see people struggle with. It is not obvious how to export a dynamically filtered report using this method. Other than the DoCmd. OpenReport -Method, the DoCmd.