Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15

    Problem while exporting to PDF

    Hi
    I built a little Access database to handle employees in my firm.


    This form is used by multiple users and it works as intended except for one single user.

    The form contains a button to export the current recordset to a .pdf file using the code
    Code:
    Private Sub Export_Click()    Dim strWhere As String
        Dim myPath As String
        Dim strReportName As String
       
    
        If Me.NewRecord Then 'Check there is a record to print
            MsgBox "Select a record to print"
        Else
            strWhere = "[Seance_ID] = " & Me.[Seance_ID]
            DoCmd.OpenReport "Report Employees", acViewPreview, , strWhere
            
    
    
            myPath = "C:\Employees\" & Year(Date) & "\" & Month(Date) & " " & MonthName(Month(Date)) & "\"
            
            strReportName = Year(Date) & "-" & Month(Date) & "-" & Day(Date) & ".pdf"
      
            DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & strReportName, False
    
    
            DoCmd.Close acReport, "Report Employees"
    
    
        End If
    End Sub
    As I already said, the code works perfectly, only one user gets a runtime error 2501 while trying to execute the code.
    Does anyone knows a solution for this issue?
    Thanks

  2. #2
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Either they don't have the C:\Employees folder or the file of the same name is already open.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    Hi Minty
    The user has the same folder permissions as everyone else and there is no file open

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Is the report failing or is the pdf creation failing? Put in the red line and see if the report is created OK. F5 or F8 will continue after the stop.
    Code:
    Private Sub Export_Click()    
        Dim strWhere As String
        Dim myPath As String
        Dim strReportName As String
    
    
        If Me.NewRecord Then 'Check there is a record to print
            MsgBox "Select a record to print"
        Else
            strWhere = "[Seance_ID] = " & Me.[Seance_ID]
            DoCmd.OpenReport "Report Employees", acViewPreview, , strWhere
            
            STOP
    
    
            myPath = "C:\Employees\" & Year(Date) & "\" & Month(Date) & " " & MonthName(Month(Date)) & "\"
            
            strReportName = Year(Date) & "-" & Month(Date) & "-" & Day(Date) & ".pdf"
      
            DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & strReportName, False
    
    
            DoCmd.Close acReport, "Report Employees"
    
    
        End If
    End Sub
    Last edited by davegri; 11-20-2018 at 12:17 PM. Reason: clarif

  5. #5
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    Hi davegri

    The report does open, the error occurs after hitting F5

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    OK. F8 will advance code one line at a time. You can then see which line causes the error.
    Also, check that the path and filename looks OK; add the msgbox
    Code:
            myPath = "C:\Employees\" & Year(Date) & "\" & Month(Date) & " " & MonthName(Month(Date)) & "\"
            
            strReportName = Year(Date) & "-" & Month(Date) & "-" & Day(Date) & ".pdf"
      	msgbox MyPath & strReportName
            DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & strReportName, False
    Last edited by davegri; 11-20-2018 at 04:05 PM. Reason: msgbox

  7. #7
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    The error occurs while executing the line
    Code:
    DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & strReportName, False
    But I really don't know whats wrong with that one, it works for everyone else and in other access databases as well

    I will try the MsgBox tomorrow at work

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    At first I figured it's because the path concatenation contains a space - Month(Date) & " " & MonthName
    because AFAIK, any path that contains spaces has to be contained in literal quotes. However, error 2501 is raised by the form or report opening action being canceled, so why only one user would raise this error is a puzzle for sure. Assuming they are not doing anything to cause this, having them log onto a pc where this has worked should tell you if it's a user profile/permissions issue. If it worked then, consider that their front end copy is a)corrupted or b)there is a problem with a table that isn't linked in their copy. That assumes the db is split and each user has their own fe copy and isn't sharing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    Well that was my first guess to, more or less, but every user is using the exact same file located on our network, and of course never more than one user at a time.
    There was another problem to, I asked the user to delete the shortcut on his desktop but he couldn,t, just as if he would try to delete an open file although it wasn't open

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Then I'd be getting that user to try to affect the target file/folder manually via Windows Explorer (not IE) to see if there's a permissions problem. They would have to attempt all the relevant operations in that folder - open, edit, delete, especially create since your code is attempting to create a file there. I have seen similar issues before, such as when someone gets modify and delete rights but administrator doesn't give create. That causes problems when Access can't create the db lock file for that user.
    Last edited by Micron; 11-21-2018 at 05:51 AM. Reason: clarification

  11. #11
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    Hi
    So I checked yesterday with the IT. The user has the same rights as everyone else. Just to be sure they cloned today the rights of another user onto the concerned one but it still won't work...

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The user has the same rights as everyone else
    Still think that unless the user can manually do what's required in the folder, I'd say that is no guarantee of anything. Did you rule out hardware, connectivity and any potential version issues? Problem user logged in using another pc as suggested? Ruled out corruption in their front end copy? They are using the correct fe version? Mostly I'd have them log on elsewhere to eliminate any of those possibilities.

    Outside of those suggestions, I have no further ideas, I'm afraid. Hopefully you will solve it and be able to post back with the solution. Good luck.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Had a weird issue where one PC could not execute one simple procedure no matter what we tried. Even reimaging the PC didn't help. Finally traded his machine with someone who did not use the db.

    Aside from user logging in elsewhere, have someone else login to problem machine.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15
    Quote Originally Posted by Micron View Post
    Did you rule out hardware, connectivity and any potential version issues? Problem user logged in using another pc as suggested? Ruled out corruption in their front end copy? They are using the correct fe version? Mostly I'd have them log on elsewhere to eliminate any of those possibilities.
    Well the weird thing is that everyone using the database is also using the same pc. So we can if fact rule out any hardware issues...
    On Monday, the user works on another station, I will ask him to try it again on that machine.

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well the weird thing is that everyone using the database is also using the same pc. So we can if fact rule out any hardware issues...
    That's a new revelation. I have seen IT and such admins give up on issues like this and simply create a new profile for someone. Their mantra must be 'I may not be able to fix it, but I can replace it'. That may be where you're headed. However, maybe try having the user test a modified output process in a test db or copy of the form, where you
    - choose another format
    - don't specify a format and wait for the prompt
    - choose another file location that the user uses on a regular basis
    - choose a different report for output

    This could be profile related, have something to do with Adobe, or data permissions. On the latter, I'm thinking of linked ODBC type databases used in your project where one user doesn't have permissions on that data set.

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

Similar Threads

  1. Problem exporting to .dbf file.
    By J Bhujanga in forum Access
    Replies: 1
    Last Post: 03-24-2017, 09:21 PM
  2. Exporting with VBA problem
    By Xarkath in forum Modules
    Replies: 3
    Last Post: 05-07-2015, 03:45 AM
  3. Problem exporting to XML
    By accexp in forum Import/Export Data
    Replies: 2
    Last Post: 09-15-2010, 12:33 PM
  4. Exporting to Excel Problem
    By octu in forum Import/Export Data
    Replies: 1
    Last Post: 04-14-2010, 11:28 PM
  5. Exporting to txt problem
    By timpepu in forum Import/Export Data
    Replies: 0
    Last Post: 03-25-2010, 12:58 AM

Tags for this Thread

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