Solved

MS Access RecordSets

Posted on 2014-10-30
8
173 Views
Last Modified: 2014-10-30
I'm using Access 2010 as a frontend to a remote SQL Server.  the tables from SQL Server are linked.  I'm trying to output data to Excel.  Getting it to Excel is not the problem but the fact that its requires the data coming from SQL Server be chopped up in many different ways is...  The process is for users to select records that will be exported into and excel report.  It could be 1 record or 20k records...  I have a form that displays the selected records and a button "Export"  that starts the process of creating the multi-tabbed Excel.  Each tab of the excel xls requires various filtering and summing and logic to be applied to the selected data set.  It's taking way to long to create the file and I believe its due to having to run a number of queries on the same data on the server over and over again.

My question is this... Seeing that I have the selected data is sitting in a form grid can I not use that data to perform all the filtering and summing rather than go back to the server 15 times?

If so, I'm trying to figure out how I would do that.
0
Comment
Question by:keschuster
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40413553
You could copy the main data from SQL Server to a local table and run your exports using this.

/gustav
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40413559
You might find it easier and quicker to pull the necessary data from the server into a temporary table that can be manipulated for your exports.  I wrote an article on using temporary tables a while back, and this was one of the scenarios I described where using a temp table can be more efficient.
0
 

Author Comment

by:keschuster
ID: 40413612
I actually use temp tables in this app - very sparingly.  My fear is as a user runs this app all day inserting and deleting records into this temp table Access will swell and exceed the 2gb limit....    If there was a way to avoid this issue aside from asking the user to compact repair every hour then I'm all it.  I just don't see how.

Because of this I starting thinking about the grids I'm creating based on queries sent to SQL Server.  I already have the data I need for the report sitting right there in front of me in a grid.  Can't i use that in someway to code against it and create the various recordsets I need to push into Excel?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40413640
If by grid you mean a form in datasheet view, you have access to the current recordset.
This you can write to a temp table and export this.

Temp tables can be held in a linked local database which you overwrite with empty data when the user opens your frontend.

/gustav
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40413874
Instead of using TransferSpreadsheet to copy the data to Excel, you can use OLE automation.  You would loop through the recordset clone of the form and populate the sheets a row at a time.  You'll need to decide for each row, which sheet to add it to so you'll need to keep track of your row position on all the sheets since you are populating them in parallel.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40413891
If you use the subroutine mentioned in my article, the act of creating the temp table, either in the front end or in a separate bd linked to your front end, can be reduced to a single line of code.  It even has arguments that let you determine how fresh you want the data.
0
 

Author Comment

by:keschuster
ID: 40413936
So Dale - your code will create the linked DB and table as needed. presumably the temp table gets dropped leaving the holding DB still there.  When the need to create the temp table again you can force it to create/overwrite a new DB and table that gets linked all over again.

Is that basically the idea?
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40413979
Right now, the act of delinking the table and deleting the file: YourAppName_temp.accdb
Is left up to you.  I usually do that with a subroutine i call when the application closes.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 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