Solved

MS Access RecordSets

Posted on 2014-10-30
8
177 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
[X]
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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 50

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 48

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
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.

 
LVL 50

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 37

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 48

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 48

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

688 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