Share via

Exporting an Access Report to Excel

Anonymous
2022-03-15T17:32:16+00:00

Hi,

I have a legacy application running on Microsoft Access 2013 (15.0.5349.1000). I just created a new report that works exactly how I had hoped in Access. Users of this application routinely export reports to .pdf. I verified that this works fine with my new report. Some users would also like the ability to export reports to Excel. When I try this with my new report, I get a message saying "Object variable or With block variable not set", and I do not get an Excel file.

As a test, I tried exporting a few other reports from this application to Excel. The reports I tried this with did not give me the error mentioned above (or any error for that matter). While a quick (not very thorough) review made me think that most if not all of the data in these reports was in fact exported, the formatting of the resulting Excel file was not even close to that of the original report.

I am hoping that someone here might be able to help me find answers to any of the following questions:

  1. Are there any common things I can look for in my new report that might be causing the error message?
  2. Are there any recommendations or guidelines I can read that explain how to preserve the formatting of an Access report when it is exported to Excel?
  3. Would upgrading to the latest version of Access help my cause?

Any suggestions or advice will be greatly appreciated.

Thanks in advance,
Paul

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. George Hepworth 22,765 Reputation points Volunteer Moderator
    2022-03-15T17:48:25+00:00

    I'm afraid you're barking up the wrong tree here. PDFs are graphical objects with limited editing capabilities. Excel is a whole other kind of object.

    I would advise against even trying to export reports to Excel like that. It's going to be a waste of time and energy.

    Instead, rely on Excel to do the kinds of things it does best, and Acrobat to do the kinds of things it does best, and Access to do the kinds of things it does best.

    Access manages data. Data can be formatted in a lot of ways, e.g. in reports. Reports are visual representations of that data. And, in turn, PDFs are visual representations (in a different format) of the visual representation of the data in the Access report.

    In order to exploit Excel's strengths you have to figure out what it does best. It CAN be formatted into a visual representation of data, but it can not be coerced into duplicating the visual representation of the Access report or the PDF. So, what to do?

    Let Access give the data over to Excel and let Excel format it in a close approximation of the visual representation. After all, your users are mostly interested in getting the right data and secondarily in how it looks. In fact, one would be tempted to wonder WHY they want it in Excel? Are they planning to perform additional summaries, additions or deletions on it once they get their hands on it? Is that a good thing, or a bad thing? Would allowing users to get the data in Excel, knowing that from there it can metamorphize into something else, be a desirable outcome? Only you and your users can decide that one.

    What you can do, then, is create a template Excel with two worksheets. The first one, which I like to call a landing page, is where you export data from Access into the workbook. It lands in table format. The second one, which I refer to as the presentation page, is pre-formatted with the layout you want users to see. Link the cells in the presentation page to the data in the landing page. That way you can allow them to see something that looks a lot like the Access report or the pdf, but takes advantage of the features of Excel to do so.

    I have a demo of this technique on my website.

    3 people found this answer helpful.
    0 comments No comments

Answer accepted by question author

  1. ScottGem 68,810 Reputation points Volunteer Moderator
    2022-03-16T11:44:34+00:00

    The error you are getting indicates a problem with VBA code. When you have such a problem it helps use help you by showing the code you are using.

    Whenever, a client asks for an export from a report to Excel, I do not try to export the report itself to Excel, instead I export the Recordsource of the report to Excel.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2022-03-20T19:58:43+00:00

    Hi GroverParkGeorge, Scottgem, and Daniel,

    Thank you for your responses. My question was sparked by a question by one of my users who tried to export a report I created to Excel so he could do additional filtering. What he was trying to do himself by using Excel, I could have easily provided a means by which he could have done this using the interface in my Access applications, and given him a more nicely formatted report. I am not sure if there is a "real" reason users will need the underlying data in Excel. If it turns out they do, they methods you guys mention sound like great ideas.

    I appreciate your help!

    Best regards,
    Paul

    0 comments No comments