Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2008, 10:18 AM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default Dynamically pass ADO recordset from Form to Report

Hi! I am trying to dynamically pass the ADO recordset that is sourcing my form to a report that needs to have the same source (same source, filter, and sort) but am having difficulty.

I am new to using ADO, but I have successfully used it to download and disconnect a recordset from SQL-Server by saving it to disk, then connect the Form's recordset to the disconnected recordset.

I am not using the ADO recordset to update the server table, but I do need to have a report preview generated that contains the same information in it that the form is showing the user. OBTW, the form uses a series of comboboxes to further filter the disconnected recordset so the report needs to be filtered in like fashion.

I have tried a number of ways to start up the report and pass it the form's recordset, but nothing seems to work.

I tried a technique that Andy Baron used to do this but it did not work for me (see below):

In the Open Event of the Report:

--------------------------------------------
Private Sub Report_Open(Cancel as Integer)
   Me.RecordSource = grst.Name
End Sub
--------------------------------------------
In my Form:

--------------------------------------------
Public grst as ADODB.Recordset

Public Sub Launch_Report_Click()

   Set grst = New ADODB.Recordset
   Set grst = Me.Recordset

   DoCmd.OpenReport "myReport", acViewPreview"
   grst.Close
   Set grst = nothing
------------------------------------------------

Any suggestions would be appreciated! Thanks!



--- Tom
__________________
--- Tom
 
Old June 19th, 2008, 11:31 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

The form would need to be open in order for the sample code to work. You could use the button that launches the report open a copy of the form in acHidden, and then have the form launch the report. Then the code would work for the On Open event of the form.

Alternatively, you could just create a form to launch the report, and have the form configure the report.

You can also create a disconnected recordset without saving it to disk. Just close the connection without closing the recordset.

Did any of that help?


mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass filter form criteria to a sub report?? Jabba007 Access 0 July 12th, 2007 09:11 PM
View an ado recordset in a form feets Access VBA 5 June 20th, 2007 06:19 AM
Convert ADO reocordset to DAO recordset use report redd Access 1 September 24th, 2004 03:34 PM
Pass Form Variable to Report (DataReport) coboy VB How-To 1 September 22nd, 2004 12:19 PM
Crystal Report From ADO Recordset Niaz Pro VB Databases 0 January 11th, 2004 04:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.