Results 1 to 8 of 8
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    export report


    All, Using 2010. I am working on a database that was created in 2003. I created a form with a button to export a report to the users desktop in a folder name "Reports". Both the user and myself have access 2010 running on a win 7 machine. When I click the button; the code runs as expected and exports the report in the folder. When the user clicks the button, they get an error :"...can't save the output data to the file you've selected." Here's the code:
    Code:
    Private Sub Export_QA_Report_Click()
    On Error GoTo Err_Export_QA_Report_Click
    Dim reportname As String
    Dim theFilePath As String
    reportname = "rptQAReport"
    theFilePath = "C:\Documents and Settings\" & Environ("UserName") & "\Desktop\Reports\"
    theFilePath = theFilePath & reportname & "_" & Format(Date, "yyyy-mm-dd") & ".xls"
    
    DoCmd.OutputTo acOutputReport, reportname, acFormatXLS, theFilePath, True
    MsgBox "Look on your desktop for the report."
        
    Exit_Export_QA_Report_Click:
        Exit Sub
    Err_Export_QA_Report_Click:
        MsgBox Err.Description
        Resume Exit_Export_QA_Report_Click
        
    End Sub
    Why can't the users run it and I can?
    Thanks

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Per this line:
    Code:
    theFilePath = "C:\Documents and Settings\" & Environ("UserName") & "\Desktop\Reports\"
    it looks like it is looking for a specific file path to place the file in. Make sure that the user having problems has such a file path on their computer (especially the Desktop\Reports subdirectory found after their username).

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Just found out that users do not have access to their Doc and Settings. How can I code it so it appears on their destop w/ or w/o a folder i.e. "reports". They do have access to "My Computer". Thanks

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I would recommend picking some common shared drive you all have access to.
    Or, another thing I have done before is to create a one-record table that stores these values, and they create a form of it so that users can change the settings themselves to a directory that they have access to.

  5. #5
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    I tried the shared drive approach but still no joy. I do remember something similar to giving the users the option where to save but don't remember the code. ???

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Its really quite simple. Just create a table that hold the export directory location, and then create a Form based on that table where the users can enter it in directory.
    I usually create the one record first, then change the Form property to not allow any additions or deletions and getting rid of all navigation buttons, to help ensure there will always be only exactly one record in the table.

    I then place a "Run" command button on Form, which runs Export, incorporating the value they entered in to the Export Directory text box. So in your VBA code, this line:
    Code:
    theFilePath = "C:\Documents and Settings\" & Environ("UserName") & "\Desktop\Reports\"
    might be replaced with something that looks like this:
    Code:
    theFilePath = Me.txtExportDirectory
    where txtExportDirectory is the name of the Text Box on the Form.

  7. #7
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Oh. This is not what I remembered. I was thinking when outputing the report; it pop ups the save dialog to prompt the users to save the report in excel format whereever they want. Forgot the code though to complete this

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You could do that too, though it may be a bit harder to program. You can do a Google Search and find that code on the internet. Here is one I used years ago" http://answers.microsoft.com/en-us/o...f-50cc0f3d3d46

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automatically export report as PDF
    By napsterxp in forum Reports
    Replies: 1
    Last Post: 04-08-2013, 04:42 PM
  2. Export report to Word
    By Lowell in forum Reports
    Replies: 1
    Last Post: 02-06-2013, 11:54 PM
  3. Export embedded report to PDF
    By Aaron5714 in forum Reports
    Replies: 10
    Last Post: 10-22-2012, 11:47 AM
  4. Report Export to Excel
    By BLD21 in forum Import/Export Data
    Replies: 1
    Last Post: 05-06-2011, 10:19 AM
  5. Export report to jpg
    By isdm in forum Reports
    Replies: 1
    Last Post: 04-16-2010, 10:00 PM

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