Solved

MS Access RecordSets

Posted on 2014-10-30
8
169 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 34

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now