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
|