Do not use on any
shared computer
August 29, 2008 04:43am pdt
 
[x]
Attachment Details

Is there a way to make a report accept a recordset / temp querydef object as its data source? (acc 97)

I'm using Access 97 to report on an ODBC linked database. Mostly, it works fine using attached tables and locally-defined and processed queries/reports. My trouble is when I'm querying a particularly large table (>45000 records).

The current situation is that I have an ordinary select query that returns the entire table, having performed a few left joins to pick up ancillary data from other attached tables. This query is the recordsource for a report, and code in the report's OnOpen event handler asks the user for a date range, and sets the Filter property accordingly.

Private Sub Report_Open(Cancel As Integer)

Dim dtStart As Date
Dim dtEnd As Date
Dim strTmp As String

dtStart = InputBox("First Date")
dtEnd = InputBox("Last Date")

strTmp = "[SHEET_DATE] >= " & Format$(dtStart, "\#d mmm yyyy\#") _
    & " AND [SHEET_DATE] <= " & Format$(dtEnd, "\#d mmm yyyy\#")

Me.Filter = strTmp
Me.FilterOn = True


This works, but it's terribly slow. Making the query passthrough makes it many orders of magnitude faster, if and only if the date range is hard-coded into the SQL. I need the date range to be user-specified. I could write some code to alter the SQL in the query definition, before activating the report, but then the query definition gets changed on a permanent basis, and for all users of the application, rather than just the current user.

So basically, the task seems to be:

1. Construct the SQL on-the-fly, incorporating user input in the WHERE clause;

2. Pass the SQL through to the ODBC driver so it can select the records at the server

3. Make the Access report accept the resulting records for printing.
pass the WHERE clause through to the ODBC driver, but also make the WHERE clause


If I could find a way to make a report accept a RecordSource or temporary QueryDef object as its data source, then I could do it. Is this possible? Is there another way to achieve the same result?



Many thanks


Vijay Samtani
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Microsoft
Question Asked By: vsamtani
Solution Provided By: DennisBorg
Participating Experts: 4
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by Paurths

Rank: Guru

Expert Comment by Paurths:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Kurvy
Expert Comment by Kurvy:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Datrias

Rank: Master

Expert Comment by Datrias:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by DennisBorg
Accepted Solution by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by vsamtani
Author Comment by vsamtani:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by DennisBorg
Expert Comment by DennisBorg:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34