Report Generation from Filtered Form

LarryB

Registered User.
Local time
Today, 08:36
Joined
Jun 19, 2012
Messages
66
Hi all,

I have a form, with subform as datasheet. I have successfully exported filtered data on the subform to excel. Ultimately I want to export the filtered data into a mail merge and selecting a template stored somewhere on a network drive.

But first I am trying to perform a simple task by creating a report based on filtered data of the sub form, which results in errors or no data.

I have tried setting the report record set in its open event

Code:
Me.RecordSource = [Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.RecordsetClone


Removing the above, I have also tried passing the subforms filter as the argument to the report

Code:
'DoCmd.OpenReport "rptDistribution", acViewPreview, , [Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.Filter

Also various other ways

Code:
DoCmd.OpenReport "rptDisribution", acViewPreview, , Nz([Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.Filter, ""), acWindowNormal

Code:
'code behind form button

DoCmd.OpenReport "rptDistribution", acViewPreview, , , acWindowNormal, Me.RecordSource = [Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.RecordsetClone


'code behind report open event
Private Sub Report_Open(Cancel As Integer)
    Me.RecordSource = Nz(Me.OpenArgs, "")
End Sub

I've also start looking at reading in the the filtered form record ID's to an array, which I can get, but then apply that to a query for my form to open is the next step.

My ultimate aim is to use the filtered records on the sub form, allow user to select a template, then the associated fields are merged.

I don't know if I am going off on a mad tangent here to what I set out to do but what I though would be the simplest of tasks is doing my nut in!! :banghead:

Any advice directions would be greatly appreciated

Cheers
 
Me.RecordSource = [Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.RecordsetClone

should be:

Me.RecordSource = [Forms]![frmDistributionRegisterMain]![DistributionSUB].Form.Recordsource
 
Hi Arnelgp

Thanks for the reply and pointing that out. The data is pulling in but as before it is pulling in the entire record source and not the filtered data.

How do I go about that?
 

Users who are viewing this thread

Back
Top Bottom