We help IT Professionals succeed at work.

MS ACCESS VBA FORMATTING

dawber39
dawber39 asked
on
182 Views
Last Modified: 2017-05-04
Hello,

I have the following code to output reports to a folder on the desktop. It keeps getting hung up on the OutputTo Cmd when I step through it. It works fine with the wait procedure and after that with opening the sendmail app, and onward. Any idea why this is getting hung up at each of the OutputTo commands for all 4 reports?  I appreciate your help on this. This is MS Access 2016

Function Email2()

    
    DoCmd.OpenReport "BuysheetJay", acViewPreview, , , acHidden
   DoCmd.OutputTo acOutputReport, "BuysheetJay", acFormatPDF, "C:\Users\Tom\Desktop\Buysheets\BuysheetJay.pdf"
  DoCmd.Close acReport, "BuysheetJay"

WaitSeconds (1)

  DoCmd.OpenReport "BuysheetJK", acViewPreview, , , acHidden
   DoCmd.OutputTo acOutputReport, "BuysheetJK", acFormatPDF, "C:\Users\Tom\Desktop\BuySheets\BuysheetJK.pdf"
   DoCmd.Close acReport, "BuysheetJK"

WaitSeconds (1)

   DoCmd.OpenReport "BuysheetFrank", acViewPreview, , , acHidden
   DoCmd.OutputTo acOutputReport, "BuysheetFrank", acFormatPDF, "C:\Users\Tom\Desktop\Buysheets\BuysheetFrank.pdf"
   DoCmd.Close acReport, "BuysheetFrank"

WaitSeconds (1)

  DoCmd.OpenReport "BuysheetOG", acViewPreview, , , acHidden
   DoCmd.OutputTo acOutputReport, "BuysheetOG", acFormatPDF, "C:\Users\Tom\Desktop\BuySheets\ BuysheetOG.pdf"
   DoCmd.Close acReport, "BuysheetOG"

WaitSeconds (1)

Dim stDBPath As String
Dim stAccessPath As String
Const Q As String = """"

stDBPath = "C:\Finished\Send2.accdb"

stAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe"

Shell Q & stAccessPath & Q & " " & Q & stDBPath & Q, vbNormalFocus


End Function

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
dawber39Database Analyst / Application Developer

Author

Commented:
Same error (See attached) even after commenting out OpenReport Lines
2501.png
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
MIS Liason
CERTIFIED EXPERT
Most Valuable Expert 2012
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
dawber39Database Analyst / Application Developer

Author

Commented:
Always can count on This site solve the problem, or point me in the right direction. Thank you
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
dawber39, since you selected three different answers, could you tell us what the actual solution was?
dawber39Database Analyst / Application Developer

Author

Commented:
There was no actual solution stated -  Jefferey's answer did make me look at the path, and that led to my discovering where the error was. The error was in the path. The destination folder was in the default desktop. The application is user specific - once I deleted the destination folder, and recreated it on the Tom desktop, it worked fine. So basically - everyone tried to help, But Jefferey pointed more in the correct direction of discovering the wrong path - hence my division of the points! Does that answer your question?
Jeffrey CoachmanMIS Liason
CERTIFIED EXPERT
Most Valuable Expert 2012

Commented:
Thanks.

Clarifying the answer also makes this Q more valuable as a PAQ.

A user searching for the same answer can easily see what the ultimate solution was...
;-)

Jeff
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Thanks Dawber.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.