Runtime Error 2302 Access Can't Save to Output File

EnginerdUNH
2StarLounger
Posts: 114
Joined: 14 Aug 2019, 00:12

Runtime Error 2302 Access Can't Save to Output File

Post by EnginerdUNH »

Hi,

I have a database user that is getting a "Run Time Error 2302: Access can't save the output data to the file that you've selected" when he runs the code to export data from the database to excel. This database is a split database with the linked tables stored on a server. He's using a laptop and only receives the error when he's working remotely but not when he's in the office. He does not remote into an office workstation from the laptop. I'm not quite sure why this error would be occurring and I'm looking to see if anyone has any ideas.

The code in question:

Code: Select all

Private Sub cmdRunReport_Click()
    Dim Username As String
    Dim strFolder As String
    Dim strFile As String
    Dim strWhere As String
    Dim objXL As Object
    Dim objWB As Object
    
    If Me.ogrpReportOpts.Value = 2 Then
        User = Environ("Username")
        strFolder = "C:\Users\" & User & "\Documents\Daily Review\"
    End If
    
    If DCount("[VND]", "qryAllActiveCombinedFilters") = 0 Then
    	MsgBox "There are no records to display in this report!", vbExclamation
        Exit Sub
    End If

    strFile = "rptAllActiveCombined.xls"
    
    DoCmd.OutputTo ObjectType:=acOutputQuery, _
    ObjectName:="qryAllActiveCombinedFilters", _
    OutputFormat:=acFormatXLS, _
    OutputFile:=strFolder & strFile
                
     Application.FollowHyperlink strFolder & strFile
End Sub

User avatar
HansV
Administrator
Posts: 79521
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Runtime Error 2302 Access Can't Save to Output File

Post by HansV »

How does he connect to the database when he's working remotely?
Best wishes,
Hans

EnginerdUNH
2StarLounger
Posts: 114
Joined: 14 Aug 2019, 00:12

Re: Runtime Error 2302 Access Can't Save to Output File

Post by EnginerdUNH »

He uses the laptop. The front end file with the forms, queries, code, and temp tables is stored on his computer and only the linked tables are stored on the server.

User avatar
HansV
Administrator
Posts: 79521
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Runtime Error 2302 Access Can't Save to Output File

Post by HansV »

Does he have a subfolder "Daily Review" in his Documents folder on that laptop?
Best wishes,
Hans

User avatar
Gasman
2StarLounger
Posts: 159
Joined: 22 Feb 2022, 09:04

Re: Runtime Error 2302 Access Can't Save to Output File

Post by Gasman »

How does he access it when in the office?, still on the laptop?
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

EnginerdUNH
2StarLounger
Posts: 114
Joined: 14 Aug 2019, 00:12

Re: Runtime Error 2302 Access Can't Save to Output File

Post by EnginerdUNH »

HansV wrote:
25 Sep 2024, 20:17
Does he have a subfolder "Daily Review" in his Documents folder on that laptop?
I have asked but not received a response yet. However, this is logically the most likely that he is missing the folder because I tried running it on my computer first with the folder removed and then again with it added back in and I got the same bug when the folder was missing

EnginerdUNH
2StarLounger
Posts: 114
Joined: 14 Aug 2019, 00:12

Re: Runtime Error 2302 Access Can't Save to Output File

Post by EnginerdUNH »

Gasman wrote:
26 Sep 2024, 08:59
How does he access it when in the office?, still on the laptop?
In the office he uses a desktop workstation and my suspicion is that when he copied the database over to both computers, he only remembered to set up the folder on the desktop but not the laptop.

Going forward on all databases that I create, I think what I am going to do is write a code that when the database is opened, it looks for and, if necessary, creates missing directories

User avatar
Gasman
2StarLounger
Posts: 159
Joined: 22 Feb 2022, 09:04

Re: Runtime Error 2302 Access Can't Save to Output File

Post by Gasman »

Going forward on all databases that I create, I think what I am going to do is write a code that when the database is opened, it looks for and, if necessary, creates missing directories
That would be a good idea, or use the FileDialog to allow the user where to put the files?
You could use your path as the default.
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.