Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Runtime error 2501

    Hello all,




    I have this code here:
    Click image for larger version. 

Name:	Screenshot 2022-12-09 170848.png 
Views:	29 
Size:	37.6 KB 
ID:	49280
    I have had this code for a very long time and have never changed it, and now suddenly this runtime error 2501 comes when I click on the button.
    Do you know what the problem is and how to solve it?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    And 2501 is?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    In the line above the yellow line add:
    Debug.Print Dateiname

    to verify that the filename is being properly created.

    The result will show in the immediate window.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Try opening the report first (hidden if you prefer) then output.
    And yes, always post the error message. No way to remember all of the thousands of messages that go with numbers, and the onus is on the original poster to provide that info.
    My suggestion is a guess, based on (I think) seeing this problem elsewhere in the last few days. As to why things stop working, it's usually because of updates.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Akchayan View Post
    Hello all,


    I have this code here:
    Click image for larger version. 

Name:	Screenshot 2022-12-09 170848.png 
Views:	29 
Size:	37.6 KB 
ID:	49280
    I have had this code for a very long time and have never changed it, and now suddenly this runtime error 2501 comes when I click on the button.
    Do you know what the problem is and how to solve it?
    Sorry, I forgot to write the error text that goes with it.
    It says: The OutputTo action was cancelled.
    I tried to implement the suggestions for improvement but it didn't work until now. Does anyone have any ideas?

  6. #6
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by davegri View Post
    In the line above the yellow line add:
    Debug.Print Dateiname

    to verify that the filename is being properly created.

    The result will show in the immediate window.
    I tried it as described, but it did not work.

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    pretty sure "PDF" is not valid, think it should be acFormatPDF (no quotes)

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    I would have thought so as well , however
    Quote Originally Posted by Akchayan View Post
    I have had this code for a very long time and have never changed it,


    I have Google on this laptop and it gives me https://www.google.com/search?q=docm...hrome&ie=UTF-8

    From that I can get https://codekabinett.com/rdumps.php?...docmd-outputto
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Welshgasman View Post
    I would have thought so as well , however

    I have Google on this laptop and it gives me https://www.google.com/search?q=docm...hrome&ie=UTF-8

    From that I can get https://codekabinett.com/rdumps.php?...docmd-outputto
    Code:
    Dim reportName As String    Dim Dateiname As String
    
    
        reportName = "repOfferte"
        Dateiname = Forms!foOfferteInhalt!AngebotNr & " Offerte " & Forms!foOfferteKundenDaten!NameKunde & " .pdf"
        DoCmd.OpenReport reportName, acViewPreview
        DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, Dateiname
        DoCmd.Close acReport, "repOfferte"
    I have updated my code like this, but the error code still comes up.

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if you debug.print Dateiname

    what do you get?

    it may not like the space before .pdf

    And perhaps it is in your variables but do you have a proper path? i.e. c:\somefolder\....

  11. #11
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    if you debug.print Dateiname

    what do you get?

    it may not like the space before .pdf

    And perhaps it is in your variables but do you have a proper path? i.e. c:\somefolder\....
    Didn't work aswell, the error occures in this line:
    Code:
    DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, Dateiname

  12. #12
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The suggestion in Post#3 (and Post#10) was not to correct the error, but to diagnose the problem. What did the Debug.Print show?
    Saying 'Did not work' and simply repeating the original problem is quite unhelpful.

  13. #13
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by davegri View Post
    The suggestion in Post#3 (and Post#10) was not to correct the error, but to diagnose the problem. What did the Debug.Print show?
    Saying 'Did not work' and simply repeating the original problem is quite unhelpful.
    Okey sorry, the same error occured. It says: The OutputTo action was cancelled.

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Please show your current code within code tags.
    Also show the output of the Debug..Print Dateiname
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  15. #15
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Okey sorry, the same error occured. It says: The OutputTo action was cancelled.
    That is not what is displayed via a Debug.Print.

    If you don't know how to properly use the Immediate Window, change the Debug.Print line before the yellow line to display a message box:

    Msgbox "Dateiname is " & Dateiname

    What does the message box show?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. 2501 error
    By Roncc in forum Access
    Replies: 37
    Last Post: 01-18-2018, 06:33 PM
  2. Replies: 7
    Last Post: 10-20-2016, 03:58 AM
  3. Runtime Error 2501 on docmd.runSQL
    By schwachmama in forum Access
    Replies: 5
    Last Post: 04-17-2015, 11:28 AM
  4. Replies: 2
    Last Post: 08-05-2013, 01:56 PM
  5. runtime error 2501 openform action was canceled
    By rumenrs in forum Programming
    Replies: 2
    Last Post: 04-11-2013, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums