SteveL13
asked on
Trying to email several reports but it takes too long
I'm trying to email several reports but it takes too long probably because each report appears on the screen and I really don't need it to do that. Here is my code presently: (Is there any way to speed up the process?) Note, I've tried acViewReport but it still appears first which takes too long.
'Email Reports...
fileNameIncomeStatement = Application.CurrentProject.Path & "\Income Statement_" & todayDateIncomeStatement & ".pdf"
DoCmd.OpenReport "Income Statement", acViewPreview, , "[Div]='" & strDivNumber & "'", acHidden
DoCmd.OutputTo acOutputReport, "Income Statement", acFormatPDF, fileNameIncomeStatement
DoCmd.Close acReport, "Income Statement", acSaveNo
fileNameSalesAnalysis = Application.CurrentProject.Path & "\Sales Analysis_" & todayDateSalesAnalysis & ".pdf"
DoCmd.OpenReport "Sales Analysis", acViewPreview, , "[Div]='" & strDivNumber & "'", acHidden
DoCmd.OutputTo acOutputReport, "Sales Analysis", acFormatPDF, fileNameSalesAnalysis
DoCmd.Close acReport, "Sales Analysis", acSaveNo
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The method you are using runs the reports TWICE. Once to open them and the second time to output them to the pdf.
You can go directly to pdf and eliminate the OpenReport step if you change the way your report gets its parameters. The OutputTo option does not provide a way to pass in the arguments directly as does the OpenReport. What I do is to use either a form control or a tempvar in my query. If the report is only run from one form, I use the form control directly. If the report can be run from multiple forms, you will need to use a tempvar.
So the report's criteria becomes:
WHERE [Div]= Forms!yourform!Div
You can go directly to pdf and eliminate the OpenReport step if you change the way your report gets its parameters. The OutputTo option does not provide a way to pass in the arguments directly as does the OpenReport. What I do is to use either a form control or a tempvar in my query. If the report is only run from one form, I use the form control directly. If the report can be run from multiple forms, you will need to use a tempvar.
So the report's criteria becomes:
WHERE [Div]= Forms!yourform!Div
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still working on this issue. Am going to try experts recommendations by end of day tomorrow. Note: The reason this take so long is that the code loops through records and produces over 100 emails.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Steve,
You selected several different answers. Did any of them actually solve the problem?
You selected several different answers. Did any of them actually solve the problem?
ASKER
Long story but to make as short as possible, the conclusion I came to was that there were 4 linked tables. For whatever reason, and I'm no network expert, the fact that they were linked was slowing to process down considerably. I ended up replacing them with make table queries and all was fine. I awarded points because of the efforts of the members to help me but also because all of the suggestions I felt were good for future.
Thanks for the explanation. Personally, I prefer to not be awarded participation points. I can't speak for the others. But a large part of the value of the questions in this forum is knowing which answer actually solved the problem. So, if one answer solved the problem selecting that one is sufficient. But if you elect to select multiple answers, it would be best to include an explanation of what answer actually did work or you can even accept your own answer and not award points at all. No expert will be offended at not being awarded participation points. It is only the trolls who will care.
ASKER
Pat. Ok. Thank you for the insight. I appreciate it and will be careful to do it that way next time.
You're welcome. The experts are continually having conversations regarding how to get questions closed accurately and without rewarding trolls. The best solution is for the poster to close his own questions (we can close abandoned questions) because only he knows if any answers solved the problem. The asker of course can award whatever points he wants to whomever he wants but it isn't really fair to spread them around just because people participated. Doing that diminishes the value of actual answers. Think of it this way - if your teacher gave a test and you were the best student in the class, would you be happy if he always averaged the scores and you got what everyone else got? How does that policy affect the best student and how does it affect the worst student? Luckily the Access forum doesn't have many trolls but some of the forums do and it is much more of a problem in those areas.
ASKER
I understand. Thank you again for your insight and all of your help.
Define what you mean by "too long"? 15 seconds? 2 minutes?