none
MS Access 2016, DoCmd.OutPutTo RRS feed

  • General discussion

  • Has anyone else encountered error 2501 when outputting to a pdf ?? I use this same EXACT code in Access 2013 and it works flawlessly. On new laptop with Office365 (Access 2016), this code generates 2501 error.

    strFile = "C:\Users\Documents\Sales Reports\MTD " & dealerName & " " & DealerNumber & " " & strToday & ".pdf"
            
            
                DoCmd.OutputTo acOutputReport, "MTD_SalesReport", acFormatPDF, strFile

    Wednesday, December 16, 2015 7:10 PM

All replies

  • Hi. Double-check that the file name you're trying to use does not have any illegal characters in it. Just my 2 cents...
    Wednesday, December 16, 2015 7:19 PM
  • I'm with DB Guy. 2501 is the "cancel" error. That can happen when trying to output as a PDF file. Put a breakpoint on your DoCmd line and find out what the actual value of strFile is. Keep in mind the Users directory can change with each new version of Windows. Plus, the directory might be protected so that you cannot just plunk in a "Documents" folder without Admin rights.

    You might be better off getting the user's "Documents" folder and create the sub folders if needed. http://www.mrexcel.com/forum/excel-questions/662733-my-documents-default-path-visual-basic-applications-irrespective-current-user.html

     

    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Friday, December 18, 2015 7:07 PM
  • Do you have a userid: Documents
    The path assumes a Documents directory under C:\Users which implies a userid of Documents.

    If you have a C:\users\Documents directory can you create a text file in it (outside of Access)?


    http://www.saberman.com

    Friday, December 18, 2015 7:19 PM