Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem w/ Overwriting Excel Export from Access 2007

Posted on 2014-03-27
6
1,165 Views
Last Modified: 2014-04-15
I am running some code that exports data based on a query to an Excel file (.xlsx) executed by a button. Previously I was exporting to a .xls file but since I have changed it to an Excel 2007 format I noticed that the file is not being overwritten. The crazy this is that when I navigate to the directory where the file is going the modified date/time is updated and the size of the file increases but when I open it I see the exact same data in there that I exported on the first execution of the code. Below is the code that I am running.

Dont know if this matters but I am exporting the file to a Sharepoint site although I stating the fully resolved path. Any assistance with this would be much appreciated.

Thank you

Public Function ExportFormData()

    On Error GoTo ErrorHandler
    
    DoCmd.SetWarnings False
    
    Dim strDashboardPath As String
    Dim strQryVacRecords As String
    
    strDashboardPath = "\\teamspace\sites\RD_TEAM\ExcelExports\"
    strQryVacRecords = strDashboardPath & "VAC_RECORDS_2014.xlsx"
    
    DoCmd.TransferSpreadsheet TransferType:=acExport, SpreadsheetType:=acSpreadsheetTypeExcel12Xml, TableName:="QRY_VAC_RECORDS", Filename:=strQryVacRecords, HasFieldNames:=True
    
    DoCmd.SetWarnings True
    
ErrorHandlerExit:
    Exit Function
    
ErrorHandler:
    MsgBox "Error No: " & Err.Number _
        & ";Description: " & Err.Description
    Resume ErrorHandlerExit

End Function

Open in new window

0
Comment
Question by:spaced45
6 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 39960198
Is it perchance appending the data instead of replacing it?
0
 
LVL 1

Author Comment

by:spaced45
ID: 39961600
I dont think so because I went back into the file before and after an export knowing that records were added and the row count was the same.
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39985418
since excel 2007 deprecated the sync between excel and sharepoint it might have changed the handling of those file types

 DoCmd.TransferSpreadsheet expects to create a new workbook (I think) so one alternative might be to check for an existing one and delete before transfer

If the problem goes away when you specifiy a non-sharepoint location then it could be you need to explicitly publish/checkin the updates in SharePoint, in Excel that would be:
Workbooks(ActiveWorkbook.Name).CheckIn
0
 
LVL 10

Assisted Solution

by:broro183
broro183 earned 250 total points
ID: 39985579
I've read that DoCmd.TransferSpreadsheet requires the path length to be less than 64 characters (see the first link). The example string that you have provided is only 60 characters so, if your real file uses the same string, this shouldn't be the cause of your problem. Is the example string the same as the one in your real file?

I think Regmigrant may be onto something with his suggestion of checking if the file needs to be "checked in".

Rob
0
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points
ID: 39985781
I've seen problems where the transferspreadsheet method is stuck in the past when using the more recent versions (2007 and after).  The method doesn't realize that the old 64k row limit has been increased with the new versions.

I usually advise developers and users to replace the transferspreadsheet method with an instantiation of an Excel object and use the CopyFromRecordset range method.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question