Solved

MS Access RecordSets

Posted on 2014-10-30
8
171 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

23 Experts available now in Live!

Get 1:1 Help Now